0
    <?php
    $args = array( 
//'posts_per_page' => 99,
'post_type' => 'course',
'category_name' => 'Consectetur adipiscing elit sed do eiusmod', //<-- custom post type category name, I have used it to find its content
'orderby' => 'date',
//'order' => 'ASC',
'ignore_sticky_posts' => 1,
'paged' => $paged);
$loop = new WP_Query($args);
if ($loop->have_posts()) :
while ($loop->have_posts()) : $loop->the_post();
    the_title(sprintf('<li><a href="%s" rel="bookmark">', 
    esc_url(get_permalink())), '</a></li>');
endwhile;
endif;
wp_reset_postdata();
    ?>

I have tried this with default post type "post" without category name its working. But woth CPT, custom post type and custom taxonomy its not working.

  • And do you use built in categories for this post type? – Krzysiek Dróżdż Oct 4 '18 at 5:58
  • @Krzysiek Dróżdż, yes with built in categories of dafult post type, its working. but with custom post type categorises with custom taxonomy not working. – Super Model Oct 4 '18 at 6:00
  • But in your code you use built in categories for CPT. Are you really tagging these posts with built in categories or do you use some custom taxonomy? – Krzysiek Dróżdż Oct 4 '18 at 6:02
  • @Krzysiek Dróżdż, 'post_type' => 'course' is a custom post type. Please correct if I am wrong – Super Model Oct 4 '18 at 6:04
  • 1
    But category_name is built in taxonomy registered for built in posts... – Krzysiek Dróżdż Oct 4 '18 at 6:05
1

To display the content, you can use the_content(), like this

while ($loop->have_posts()) : $loop->the_post();
    the_title(sprintf('<li><a href="%s" rel="bookmark">', 
    esc_url(get_permalink())), '</a></li>');
    the_content(); // render content
endwhile;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.