WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Smarter Navigation] What about query_posts? (8 posts)

  1. chavo
    Member
    Posted 4 years ago #

    Hi Scribu. Another great plugin of your own. Your rocks man!.

    I'm having an issue with query_posts at the index page. I have 2 categories in my site: "portfolio" and "news / blog". At the home page, I made a query_posts from portfolio category, so I display all post into it child categories. When I'm going to a single post from category archive, the plugins works like a charm. But when I'm going to a single post from home page, the next/previous links also links to posts into "news / blog" child categories. I tried placing the code as it follows:

    <?php previous_post_smart ('%link','prev', TRUE, '10 and 11'); ?>
    <?php next_post_smart ('%link','next', TRUE, '10 and 11'); ?>

    (10 and 11 are the cat ID for news / blog child categories).

    Do I doing anything wrong?.

    Thanks in advance and sorry for my english.

  2. scribu
    Member
    Posted 4 years ago #

    Currently, the plugin has to store the prev / next posts before any theme file is read. This means that it ignores your query_posts() command.

    So you're not doing anything wrong - it's just a limitation in the plugin.

    By the way: you can remove '10 and 11', since it's also ignored.

  3. chavo
    Member
    Posted 4 years ago #

    Ok. Thank you scribu!

  4. chavo
    Member
    Posted 4 years ago #

    Hi Scribu. I was thinking about this issue. Is there a way to harcode the plugin to do something like "If you come from home, prev and next buttons have to navigate between portfolio category"?.

    Thanks.

  5. scribu
    Member
    Posted 4 years ago #

    Try this:

    Open main.php and find these lines:

    if ( $previous )
    	return previous_post_link($format, $title);
    else
    	return next_post_link($format, $title);

    Replace them with this:

    if ( $previous )
    	return previous_post_link($format, $title, true);
    else
    	return next_post_link($format, $title, true);
  6. chavo
    Member
    Posted 4 years ago #

    Nothing changes.

    Update:

    Works with this hardcode:

    if ( $previous )
        return previous_post_link($format, $title, FALSE, '10 and 11');
    else
        return next_post_link($format, $title, FALSE, '10 and 11');
  7. smartyd
    Member
    Posted 4 years ago #

    My 'main' doesn't have those lines. But here is my paginate.php which I assume is where I would want to make the changes:

    <div id="pnav">
    <div class="alignleft"><?php previous_post_link('« %link') ?></div>
    <div class="alignright"><?php next_post_link('%link »') ?></div>
    </div>
    <?php } else if (is_page()) { ?>
    <div id="pnav">
    <?php link_pages('Page: ', '', 'number'); ?>
    </div>
    <?php } else { ?>
    <div id="pnav">
    <div class="alignleft"><?php previous_posts_link('Previous Post'); ?></div>
    <div class="alignright"><?php next_posts_link('Next Post'); ?></div>
    </div>
    <?php } ?>

    Where would I put the category I don't want to be included in the "previous" and "next" links?
    (See how the navigation works when calling up a single page on http://www.theamazingagingmind.com)
    Thanks!

  8. smartyd
    Member
    Posted 4 years ago #

    Got it. Changed to:

    <div class="alignleft"><?php previous_post_link('%link', '%title', FALSE, '30') ?></div>
    <div class="alignright"><?php next_post_link('%link', '%title', FALSE, '30') ?></div>

Topic Closed

This topic has been closed to new replies.

About this Topic