WordPress.org

Ready to get started?Download WordPress

Forums

The Erudite
How to make latest article use the excerpt on front page? (3 posts)

  1. Christiaan
    Member
    Posted 1 year ago #

    How do I make the latest article use the excerpt on the front page instead of displaying the whole post.

  2. Tunbosun Ayinla
    Member
    Posted 1 year ago #

    All you need to do is make use of the is_front_page() conditional tag.
    You will also have to fetch the latest post using the WP_Query

    Am example is shown below.

    <?php 
    
    $args = array(
    'posts_per_page' => 1; //this fetch only the first recent post
    );
    
    $loop = new WP_Query( $args );
    if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();
    
    if( is_front_page(): )
    the_excerpt();
    endif;
    
    endwhile;
    endif;
    
    ?>
  3. Christiaan
    Member
    Posted 1 year ago #

    Thanks Tublz, any idea exactly what I should edit in the Erudite theme?

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags