shortcode - Content included from pagination

admin2025-06-05  8

I appreciate if someone can help me to explain why my post content shows below the pagination even though I echo the title only.

I call this code via shortcode.

INPUT:

// the query to set the posts per page to 3
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array('posts_per_page' => 3, 'paged' => $paged );
query_posts($args); 

if ( have_posts() ) : 

    while (have_posts()) : the_post(); 

        echo "<h2><a href='".get_the_permalink()."'>".get_the_title()."</a></h2>";

    endwhile; 

    the_posts_pagination( array(
            'mid_size' => 2,
            'prev_text' => __( 'Previous page', 'findarch' ),
            'next_text' => __( 'Next page', 'findarch' ),
            'screen_reader_text'    => __('navigation','findarch')
            ) );

else : 
    echo "NOT FOUND.";
endif; 

wp_reset_postdata();

OUTPUT:

43e
Hello world!
navigation
Previous page 1 2 3 4 

asdasd

dsad

as

das

d

asd
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749075989a316150.html

最新回复(0)