WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Limit have_posts() to one category (2 posts)

  1. xrun
    Member
    Posted 1 year ago #

    Hi.
    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 http://site.com/blog instead of http://site.com/category/blog/
    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?

  2. xrun
    Member
    Posted 1 year ago #

    Solved. For reference:

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

Topic Closed

This topic has been closed to new replies.

About this Topic