[Support request] Is it possible to have Page Excerpts in the same way as Post Excerpts

Home Forums Support [Support request] Is it possible to have Page Excerpts in the same way as Post Excerpts

Home Forums Support Is it possible to have Page Excerpts in the same way as Post Excerpts

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1347540
    Gillian

    Hi

    I would like to be able to have Page Excerpts in the same way as we hove Post excerpts – really just to deal with some password protected pages where some of the information showing in the automatic capture shouldn’t be on show. I read that it could be done, but the code supplied needs to be adapted for the appropriate theme.

    Another way to display page excerpts is by adding the code directly to your theme files. You can create a custom page template and add the following code as an starting point.

    
    	
    $args = array(
    'post_type' => array( 'page' ),
    'posts_per_page' => 10,
    ); 
    // The Query
    $the_query = new WP_Query( $args );
     
    // The Loop
    if ( $the_query->have_posts() ) {
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            echo '<h3>'. get_the_title() . '</h3>';
            the_excerpt();
        }
        /* Restore original Post Data */
        wp_reset_postdata();
    } else {
        // no posts found
    }
    

    You will need to adjust the code to match your theme templates.

    Thanks

    #1347736
    Leo
    Staff
    Customer Support

    Hi there,

    Where would the page excerpt be displayed?

    There isn’t an archive for pages like an archive/blog for posts.

    Let me know 🙂

    #1347815
    Gillian

    I want it to replace the meta data which appears below the page title eg in Google searches or if you send someone the link to the page via Whats App

    #1348131
    David
    Staff
    Customer Support

    Hi there,

    are you using an SEO plugin as they generally provide a meta description which would be used for sharing content.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.