简体   繁体   中英

Custom post by Shortcode How to Show Wordpress Pagination (index.php)

I replaced my blog post with my custom post by using shortcode in index.php but the pagination doesnt show.

here is my code

 <?php get_header(); ?> <div id="content-box" class="row"> <main id="content" class="col-sm-9"> <?php echo do_shortcode('[ktzagcplugin_image source="yahoo" number="20" related="true" keyword="my blog keywords"]');?> </main> <?php get_sidebar(); ?> <?php the_posts_pagination(); ?> </div> <?php get_footer(); ?> 

it means there are 20 custom posts in my homepage, i wanna separate them by pagination. but it doesnt show.

You need to review a code of the_posts_pagination function. This function is point to get_the_posts_pagination . The last function getting global $ wp_query variable and using it for create the pagination block.

I think you shortcode not initialize global variable $ wp_query and get_the_posts_pagination hasn't data for create a pagination block.

You must to implement the pagination in plugin where your shortcode is implemented

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM