WordPress.org

Ready to get started?Download WordPress

Forums

Smarter Navigation
Conditional for showing next/previous links when there's only one (7 posts)

  1. Sunny_Balanga
    Member
    Posted 3 years ago #

    Plugin's great, but..

    I style the background of the next/previous link navigation area with css. The styling shows up even when there are no next/previous posts, which looks silly.
    It used to be like that with pre WP 3 versions of WP, but they finally fixed it and it doesn't happen anymore.
    However, now that I've installed the "Smarter Navigation" plugin, I'm experiencing this problem again.
    I'd love a fix for this if possible.
    If I haven't been clear, I can post some screen-shots - my site is not live yet.
    Thanks.

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Please paste the code you are using to display the navigation links.

  3. Sunny_Balanga
    Member
    Posted 3 years ago #

    Hi,

    Thanks for answering.

    This is the code for navigation links:

    <div id="nav-below" class="navigation">
    <div class="nav-previous">
    <?php previous_post_smart( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentyten' ) . '</span> %title' ); ?>
    </div>
    <div class="nav-next">
    <?php next_post_smart( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentyten' ) . '</span>' ); ?>
    </div>
    </div>

    Here's the CSS for class "navigation" - the problem is that the CSS shows up even when there are NO links:

    background: yellow url(/images/overlay.png);
    border: 1px solid black;

  4. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Ok, and you say that if you use the regular previous_post_link() and next_post_link() the problem goes away?

  5. Sunny_Balanga
    Member
    Posted 3 years ago #

    Hi,

    Thanks, again for responding.

    I was going to say yes to your question above, but decided to check again. I Disabled the plugin ad lo and behold, the styling was still showing up.

    WordPress does a good job hiding navigation for post pages, but a lousy job for hiding it on the single post view.

    Seems that you can set background color to "navigation" and it won't show if there are no previous/next posts (which made me believe no css would show), but if you set any margins, padding, width or border, the styling shows up and this has NOTHING to do with plugin.

    That said, I now wonder even more if there's something you could add to the plugin so as to eliminate the display of the "navigation" element altogether when there is only ONE post.

    Thanks.

  6. Sunny_Balanga
    Member
    Posted 3 years ago #

    I've published my site, so here are some examples for what I'm talking about:

    Here's an example when there are previous/next links and how the navigation area css styling looks: http://www.sunnybalanga.com/blog/2010/10/09/wordpress-white-screen-of-death-upon-comment-post/

    And here's an example of a post that is the only post in its category. I have been able to style the navigations links as above without using margins, padding or width, but I had to keep the borders, and as you can see, they show up where the link navigation area is. http://www.sunnybalanga.com/blog/2010/09/26/in-the-works-for-wamp/

    I'm hoping that since your plugin manipulates the navigation that it might be feasible for you to do something about this..

  7. Sunny_Balanga
    Member
    Posted 3 years ago #

    Hi again,

    I'm still trying to solve my problem with hiding the "navigation" div when there is only one post in a specific category.

    I have actually managed to do it, but the 'fix' presents a new problem.
    If I go into single post view via archives, author or tags, navigation links disappear when the previous/next post is of a different category than the first post viewed.

    Could you please explain, perhaps with examples too:

    (1) How to use get_referrer_url.
    (2) How to use the $fallback parameter for previous_post_smart() and next_post_smart().

    I am hoping that perhaps one or both of these may help facilitate what I am trying to achieve. More specifically, I'd like to be able to use 2 different single.php templates: 1 for displaying posts by category, and another for displaying posts by any of archives, authors and tags.

    Any help you may be able to offer will be greatly appreciated.. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic