Support » Themes and Templates » Limit have_posts() to one category

  • Resolved xrun


    I’m building a media site, and have categories for several portfolio subjects, and I have a blog category. I’d like this blog category to show up on a page I call “Blog” and put that page in the menu to avoid putting a link to the category cause doing this would give a long url with the words archive or category in it. Just to keep the url simple so to speak. This would look better when sharing the link too, just instead of
    I’ve tried working with the permalink structure, but once I go into a category archive the url gets those extra words.

    So, I’ve made a page called Blog, and I’ve modified a copy of the archive template file and use it as a page-template. Then I added query_posts( 'cat=3' ); to the code, to make it only fetch the blog category, which it does.

    The problem is that it doesn’t paginate correctly. There is pagination in the template, but when I go to the next page it shows the same content as on the first page, same posts instead of the next ones.

    I’m obviously missing something. Could someone please offer some assistance?

Viewing 1 replies (of 1 total)
  • Solved. For reference:

    <?php	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	query_posts('cat=3&posts_per_page=3&paged=' . $paged);

Viewing 1 replies (of 1 total)
  • The topic ‘Limit have_posts() to one category’ is closed to new replies.