• Hi,

    I’m making a new site which will have a few blocks in the footer made up of excerpts from the content from various internal pages of the site. How do I display these excerpts? I’ve been searching around for an answer, and as far as I understand, the mysteries of WP_Query can help me here, but I don’t know to construct the query that I should use. Can anyone show me where and how to begin with this?

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter snthr

    (@snthr)

    Here’s an update on this. I have this thing semi-working, but it only displays the four most recently-added pages:

    <?php
    $args = array(
        'post_type' => 'page',
        'post_status' => 'publish',
        'posts_per_page' => 4,
    );
    $query = new WP_Query($args);
    while ($query->have_posts()) {
        $query->the_post();
        ?>
    
    <?php echo '<div class="block"><h3>'; echo the_title(); echo '</h3> <p>'; echo get_the_excerpt(); echo '</p></div> <!-- .block -->'; } ?>
    
    <?php wp_reset_postdata(); ?>

    Is there anything I can do to get it to display four specific pages? Can I mark the pages in some way to have them be output in the footer? Or, failing that, can I add in the specific IDs for those pages in the above code somewhere?

    Thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘Add page excerpts to footer – perhaps with WP_Query?’ is closed to new replies.