• Resolved akhawkes

    (@akhawkes)


    Hi,
    I thought this would be pretty simple.
    I would like to add blog excerpts to the front of the home page and still display all the content that is on the page, however I would like to the blog to post above all other content.

    Here is a link to the site https://www.DerekBoyer.com

    I have tried multiple different approaches, taking the page.php file and cloning that and renaming it as a different template and adding different lines of code that I have found in the forums, however noting seems to work, they display the blog excerpts but not the page content…

    Any help or direction is greatly appreciated

    Thanks in advance

    Andrew

Viewing 5 replies - 1 through 5 (of 5 total)
  • You probably want to add an independent WP_Query that will execute for that page only.

    1. Make sure your home page is running with its own template file.

    2. Within that file, add something like the following:

    <?php
    $excerpts = new WP_Query( array(
        'post_type' => 'posts',
        'post_status' => 'publish',
        'posts_per_page' => 5
    ) );
    
    if ( $excerpts->have_posts() ) :
    ?>
    <ul>
    <?php
        while ( $excerpts->have_posts() ) : $excerpts->the_post();
    ?><li><?php the_excerpt(); ?></li><?php
        endwhile;
        wp_reset_postdata();
    ?></ul><?php
    endif;
    ?>

    Untested, but that’s the general idea. Hope it helps!

    Thread Starter akhawkes

    (@akhawkes)

    Awesome, thank you alchymyth and Andy, this has certainly helped… just the spinet I was missing, only having an HTML knowledge didn’t help much, so I will be looking here more to get my head around php and wordspress thank you.

    Thread Starter akhawkes

    (@akhawkes)

    Worked perfectly thank you both again, most thankful

    How do I add the featured image for each post to this?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add blog excerpts to static home page’ is closed to new replies.