Reputation: 1034
I've got post_type = portfolio in my wordpress page, and with this code I get the category of each post:
$terms = get_the_terms( $post->ID, 'portfolio_category' );
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
But it's not working correctly. It shows the category of current post, and of all posts before. How to fix it?
Upvotes: 0
Views: 104
Reputation: 180
use this code for specific category
<?php
global $post;
$args = array( 'numberposts' => 5, 'category' => 3 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
setup_postdata($post); ?>
<?php the_title(); ?>
<?php the_content(); ?>
Chnage the number of post and category ID....
Upvotes: 3