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

Question

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> 
<p>
<?php
    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 );
        endwhile;
    else:
        echo '<p>Oops! Something went wrong</p>';
endif;
?></p>

<?php 
// 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() ) : ?>

<ul>
    <!-- the loop -->
    <div>
        <?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(); ?>">
                <div>
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                </div>
            </li>
        <?php endwhile; ?>
        <!-- end of the loop -->
    </div>
</ul>

    <?php wp_reset_postdata(); ?>

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

Leave an answer

Browse
Browse