- This topic has 6 replies, 2 voices, and was last updated 4 years, 6 months ago by
Tanvir.
Hi,
i need to create a page passing a parameter to view some manuals
I’ve made this script and it works fine to show all files, but i don’t know how to view subcategory for each file
In particular: i have to show all manuals of a product (my category), but they are in more languages (my subcategories) and i want a view like
Product
Language 1
Files language 1
Language 2
Files language 2
My script now is this, i have only to add subcategories but i dont’ know how to do
/** MANUALI ENG ********************************************************/
public function createDocumentListsManualEng( $atts, $content = null ) {
$terms = $atts['product_slug'];
$loop1 = new WP_Query( array( 'post_type' ► 'wpdmpro',
'tax_query' ► array(
array (
'taxonomy' ► 'wpdmcategory',
'field' ► 'slug',
'terms' ► $terms,
)
), 'posts_per_page' ► -1 ) );
$html = '<div id="inno-docs">';
if( $loop1->have_posts() ) {
$html .= '<div class="inno-doc"><h3>MANUALS ' . $terms . '</h3><ul class="inno-scrollable">';
while( $loop1->have_posts() ) {
$loop1->the_post();
$html .= '<li><a href="' . wp_get_attachment_url( get_post_meta( get_the_ID(), 'documento_allegato', true ) ) . '" target="_blank">' . get_the_title() . '</a></li>';
}
$html .= '</ul></div>';
wp_reset_postdata();
}
return '<div id="inno-logged-in">'.$html.'</div>';
}
-
This topic was modified 4 years, 6 months ago by
Assistenza Project.
Hello @assistenzapj
You can use this free addon for the same purpose
However you can add 'include_children' ► false/true to disallow/allow subcategory.
Thanks
Hi thanks for your fast response
Where i have to use ‘include_children’ ► false/true ?
Hello @assistenzapj,
You can use that in array like this:
....
'field' ► 'slug',
'terms' ► $terms,
'include_children' ► false
...
If you download and check the WPDM Extended Shortcodes Addon and check the codebase, you will get more idea about the category and subcategory structure of WPDM. Because the addon deals with same tasks. Let me know if you have any other questions.
Thanks
Hi, i’ve set like your example but i don’t view subcategories
I think i’ve got to add something here where i get the title?
$html .= '<li><a href="' . wp_get_attachment_url( get_post_meta( get_the_ID(), 'documento_allegato', true ) ) . '" target="_blank">' . get_the_title() . '</a></li>';
Hi, anyone can help me for this? Thanks
Sorry your issue is not clear to me. We can provide support with our plugins and addons. If you can’t code of subcategories, I think using and analyzing this addon will be better for you: Please check it and it’s shortcodes and analyze how it works.
Thanks
The topic "Script for view category, subcategory and files" is closed to new replies.