WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Query Posts Problem (4 posts)

  1. thejester12
    Member
    Posted 6 years ago #

    Hello all, I'm working on a custom theme for my website. It's getting a little complicated because I'm trying to do a few things. I think I've got it all working except for the "Older Entries" and "Newer Entries" links to work on the main index theme page. Even though they link correctly, the same posts stay up.

    Part of the problem, I realize, is that I'm using the Query Posts feature. I learned about how to get pagination back from this post.

    Unfortunately, even though I implemented some of that code, I still seem to be having problems.

    If anyone could help me out, that would be very appreciated, here is the code for my theme's index page on pastebin:

    http://wordpress.pastebin.com/m193d1e48

  2. thejester12
    Member
    Posted 6 years ago #

    Please? Could someone maybe just look at the code and see if they have any ideas? Your help would be really appreciated.

  3. Kafkaesqui

    Posted 6 years ago #

    Change your first use of query_posts to:

    <?php $posts_query = new WP_Query('cat=14&showposts=3'); ?>
    <?php if ($posts_query->have_posts()) : while ($posts_query->have_posts()) : $posts_query->the_post(); ?>

    That should clear up the conflict on the page.

    References:
    http://codex.wordpress.org/The_Loop#Multiple_Loops
    http://codex.wordpress.org/Function_Reference/WP_Query
    http://codex.wordpress.org/Template_Tags/query_posts

  4. thejester12
    Member
    Posted 6 years ago #

    Thank you so much, this is awesome! I tried it out and it worked like a beaut!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.