• Right now, i am using code below to show title and its link of recent posts from my custom post category, but for one of my category i want to show excerpt, how can i achieve that.

    CODE i am using to display title:

    <?php
        $recent_posts = wp_get_recent_posts(array('post_type'=>'jokes'));
        foreach( $recent_posts as $recent ){
            echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
        }
    ?>
Viewing 1 replies (of 1 total)
  • akapellos

    (@salat-production)

    if( !empty($post->post_excerpt) ) {
                the_excerpt();
                } else {
                   echo wp_trim_words(get_the_content(), 20); } ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • The topic ‘How to get excerpt of the recent posts’ is closed to new replies.