Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

sgutauckis on "How to Display Media Files for Specific Categories"

$
0
0

A site that I am working on is for various laser models. Each model has drivers, help files, etc.
Based upon the models page, I want to be able to automatically list, by category the media files associated with that laser model, by category.
So for example if we go to the page for the C180 Laser you would get:

Drivers
Update1.zip
Update2.zip
Instructions
Instructions1.pdf
Instructions2.pdf
Instructions3.pdf

I am comfortable coding in PHP and have tried using the WP_Query class but its not working as I would expect.

I was trying their example code shown below.

// The Query
$the_query = new WP_Query( 'category_name=c180+drivers' );

// The Loop
if ( $the_query->have_posts() ) {
	echo '<ul>';
	while ( $the_query->have_posts() ) {
		$the_query->the_post();
		echo '<li>' . get_the_title() . '</li>';
	}
	echo '</ul>';
} else {
	// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

But this returns nothing.
I am setting the media categories after uploading the files so I know that is set.


Viewing all articles
Browse latest Browse all 8245

Trending Articles