WordPress.org

Ready to get started?Download WordPress

Forums

Cannot include navigation in single posts (5 posts)

  1. insurgenesis
    Member
    Posted 1 year ago #

    Hi, I'm using a child theme for twenty eleven but thought this would be a more general issue.

    I've managed to include custom navigation for my category posts by calling a function like this <?php blah_pagination(); ?> from within the category.php template.

    The function itself resides in functions.php and looks like this: http://pastebin.com/G1TNrTnv

    For some reason it cannot be called in the same way from the single post (single.php and content-single.php) template.

    Is there another, improved way to do this? Why won't it work?
    My php skills are limited and I'm done guessing...

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    what do you want to do different than what Twenty Eleven does already with the code in single.php:

    <nav id="nav-single">
    						<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
    						<span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">←</span> Previous', 'twentyeleven' ) ); ?></span>
    						<span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></span>
    					</nav><!-- #nav-single -->
  3. insurgenesis
    Member
    Posted 1 year ago #

    It's very confusion when a single post is presented outside the cycle in which the posts belonging to a category are arranged.

    In my case, single posts were presented differently from posts in categories (although ALL the posts are in categories).

    To counteract this I included the category name above single posts and confined "next" and "previous" to only navigate in the category to which a single post had been assigned to.
    But "previous" and "next" needed more options like "page 1 of 1" because it felt too limiting.

    I then found a function (above link) that works for category.php but not for posts generated with the singles. Now the challenge is to get some consistence between category- and single posts navigation.

  4. insurgenesis
    Member
    Posted 1 year ago #

    alchymyth, do you understand what I mean?
    The navigational style described above (before alternative solutions were introduced) is how it ended up to be in my child theme.
    Although I realise Twenty Eleven comes with its own navigation solutions I just needed a little more. It's important to note that I did not do away with it either but the idea was to build on it.
    Anyway I hope I'm not being too particular. If I should be posting this in another forum, please let me know.

  5. insurgenesis
    Member
    Posted 1 year ago #

    @alchymyth, maybe I haven't yet responded to your question:

    what do you want to do different than what Twenty Eleven does already with the code in single.php?

    I needed a way to show navigation options more explicitly.
    The navigation I used not only shows "next" and "previous" but also includes "first/last", as well as a numeric pagination 1,2,3 etc.

    I have tried to explain this elsewhere on the forum. The original OP question was:

    How can I set ONE template to be used for ALL posts - such as category.php instead of using multiple ones?

    I don't understand the need for the single template. I guess I need a more static feel. Although I got navigation working for the category posts only, the real issue is that single posts seem to fall outside the cycle.
    Do you know what I mean?

    I certainly don't expect answers relating to custom navigation implementation but it would be beneficial to learn more about the inner workings of that "cycle". And I realise there's a semantic difficulty in describing this to someone, my apologies. It would be more reassuring to know that the cycle issue is real than simply solving the navigation.

Topic Closed

This topic has been closed to new replies.

About this Topic