Custom Post type posts in category page not show

Posted in: Newsmag
Post count: 15

hi,

Custom post type posts not show in category page but i see post in taxonomy page, filter page and menu.

i dont find category page loop chance i try this replace this code did not work well enough

// Old Code
<?php locate_template(‘loop.php’, true);?>

// New Code
<?php
// WP_Query arguments
$args = array (
‘post_type’ => array( ‘post’, ‘galeri’),
‘post_status’ => array( ‘publish’),
‘cat’ => $cur_cat_id,
‘posts_per_page’ => ’10’,
);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
echo ‘<div class=”yenikategori”>
<div class=”td-block-span6″>
<div class=”td_module_1 td_module_wrap td-animation-stack”>
<div class=”td-module-image”>
<div class=”td-module-thumb”>’,
‘,
get_the_post_thumbnail( $post_id, array( 300, 160) ),

</div>’;
cat_slug.'” class=”td-post-category”>’.$category[0]->cat_name.’</div>’;
echo ‘ <h3 class=”entry-title td-module-title”>’;
echo ‘ ‘.get_the_title( $id ).’
</h3>’;
echo ‘<div class=”td-module-meta-info”>
<div class=”td-post-date”>’;
echo ‘<time class=”entry-date updated td-module-date” >’.get_the_date().'</time>’;
echo ‘</div>
</div>
</div>
</div>
</div>
</div>’;

}
} else {
// no posts found
}

// Restore original Post Data
wp_reset_postdata();
echo ‘</div>’;
?>

Post count: 6535

Hi

In order to have posts from from custom taxonomies on a page you need to a add these taxonomies to your new query using tax_query parameter. For more details about how to add custom taxonomies to query check these links: https://codex.wordpress.org/Class_Reference/WP_Queryhttp://www.codeinwp.com/blog/getting-posts-wp_query-class/

Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newsmag’ is closed to new topics and replies.