How to get ALL posts in a category using Wordpress?

This works well, except that it is limited to 10 posts, as my blog is set up for a maximum of 10 posts.

   $featured_query = new WP_Query('cat=3');

        while( $featured_query->have_posts() ){
            $featured_query->the_post();
            $postcount++;
            ...

How can I override this parameter and get ALL messages in this category, regardless of whether the maximum message values ​​are set?

+3
source share
3 answers

Use showposts=-1. This will change the default setting. To do this: http://codex.wordpress.org/Template_Tags/query_posts#Post_.26_Page_Parameters

+1
source

Do query_posts ('cat = 3') do what you want?

0
source

.

>  $catPost = get_posts(get_cat_ID("NameOfTheCategory"));

> foreach ($catPost as $post) : setup_postdata($post); ?>
>        <div>
>              <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
>              <p><?php the_content(); ?></p>
>        </div> <?php  endforeach;?>

MrPhpGuru

0

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


All Articles