Breakdown of custom WordPress requests

I have a WordPress site where on the main page I list content from more categories.

My question is: is there a plugin where I can paginate results from a category? I mean something like $this->plugin_paginate('category_id');or smth?

Regards,

+3
source share
4 answers

If you use the standard Wordpress loop, even with query_postsfor category, pagination is automatic with regular posts_nav_link. Are you trying to split pages into multiple queries and more than one category on one page?

11/20: , :

<?php
$my_query = new WP_Query('category_name=mycategory&showposts=1');
while ($my_query->have_posts()) : $my_query->the_post();
?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>

, : " WordPress

, . . , Wordpress.

+1

, , query_posts(). , .:)

, query_posts(), :

// let get the first 10 posts from category ID 3
query_posts('posts_per_page=10&cat=3');
while(have_posts()):the_post();
    // do Wordpress magic right here
endwhile;

, 11 20 3 ( NEXT 10 ), [offset] query_posts():

// let get the next 10 posts from category ID 3
query_posts('posts_per_page=10&cat=3&offset=10');
while(have_posts()):the_post();
    // do Wordpress magic right here
endwhile;

. , ? , , , .

- , , Javascript, , , .

0

, - :

    <?php
        if(isset($_GET['paged'])){
            $page = $_GET['paged']-1;
        }else{
            $page = 0;
        }
        $postsPerPage = 5;
        $theOffset = $page*$postsPerPage;
    ?>
    <?php query_posts(array('posts_per_page' => $postsPerPage, 'cat' => CATEGORIES HERE, 'offset' => $theOffset)); ?>
0

, :)

<?php
   $args = array(
  'post_type' => 'post',
  'posts_per_page' => 5,
  'paged' => $page,
  );

  query_posts($args);?>
?>
0

Source: https://habr.com/ru/post/1723287/


All Articles