I've created a custom post type with categories and sub categories, what I need to do is list out the post titles and images for a given sub-category or category in a page template.
I've got as far as getting the all the listed items in the custom post type, but I'm unsure how to go further... any help appreciated.
<?php
$args = array( 'post_type' => 'portfolio', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="infoflowing-style">';
the_content();
echo '</div>';
endwhile;
?>
Comments
This should work:
I think it's possible the below code did not work because it uses a deprecated parameter (I think caller_get_posts was deprecated in 3.1)
Think the below should sort things out:
Couple of things to consider as well (sorry if this crosses into 'obvious' territory!):
1) is your custom post type registered to use the built in categories or is it a custom taxonomy that it's using? If the former then the above should work, if the latter then you would need to use 'your-taxonomy-name'=>'your-taxonomy-term' in place of the cat=>5 parameter
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
2) Do you have any other loops running on the page? If so they will need
after them in order for subsequent loops to work properly
http://codex.wordpress.org/Function_Reference/wp_reset_query
Add Comment