How can I get the correct content of the Posts page?


I’m using static pages for homepage display. I’m able to use the get_the_content to show my Homepage content/description(front-page.php). I’m trying to get the content/description of the Posts page(home.php),

enter image description here

but instead it’s showing the content of every blog posts as the Posts page content.

enter image description here

//This is the Page Title
<h1><?php single_post_title(''); ?></h1> 
    if (have_posts()):
        while (have_posts()) : the_post();
            // This should display the Post page content but it's showing the 
            // content of all the blog posts from the <ul>
            $content = get_the_content(); 
            echo wp_filter_nohtml_kses( $content );
        echo '<p>Oops! Something went wrong</p>';

// This shows the list of blog posts with their thumbnail and title
$wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?>

<?php if ( $wpb_all_query->have_posts() ) : ?>

    <!-- the loop -->
        <?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
            <li class="">
                <img src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>">
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
        <?php endwhile; ?>
        <!-- end of the loop -->

    <?php wp_reset_postdata(); ?>

<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
, Cypher 4 years 2020-02-18T08:38:26-05:00 0 Answers 51 views 0

Leave an answer