Script for view category, subcategory and files

Viewing 7 posts - 1 through 7 (of 7 total)
#158367

Assistenza Project
Participant

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>';	
	}
	
#158371

Tanvir
Moderator

Hello @assistenzapj

You can use this free addon for the same purpose

WPDM Extended Short-codes

However you can add 'include_children' ► false/true to disallow/allow subcategory.

Thanks

#158372

Assistenza Project
Participant

Hi thanks for your fast response
Where i have to use ‘include_children’ ► false/true ?

#158375

Tanvir
Moderator

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

#158389

Assistenza Project
Participant

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>';
#158939

Assistenza Project
Participant

Hi, anyone can help me for this? Thanks

#158955

Tanvir
Moderator

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.

WPDM Extended Short-codes

Thanks

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Script for view category, subcategory and files’ is closed to new replies.