WordPress.org

Ready to get started?Download WordPress

Forums

display category name in previous/next links (4 posts)

  1. laaroo
    Member
    Posted 6 years ago #

    I am using previous/next_post_link but I would like state "Previously in (current category name)" right now i have %title in its place.
    Is there an easy way to automatically pull the category name into the link

    <div class="alignleft"><?php previous_post_link('&laquo; %link', 'Previously in %title', TRUE, '102'); ?></div>
    <div class="alignright"><?php next_post_link('%link &raquo;', 'Next in %title', TRUE, '102'); ?></div>

    Thanks!

  2. Anonymous
    Unregistered
    Posted 6 years ago #

    I'm also looking for the exact same thing, anyone know the answer to this?

  3. thirdeyetc
    Member
    Posted 6 years ago #

    I too would like to do this. I have an online store, and it'd be great if I could get it to say "next store item" or "next news item" etc..

    has this been resolved? Currently using title as above.

  4. slackermethod
    Member
    Posted 5 years ago #

    You guys are looking for something like this.

    <div class="alignleft"><?php
    			$category = get_the_category();
    			$cat_name = $category[0]->cat_name;
    			previous_post_link('&laquo; %link', 'Previously in '.$cat_name, TRUE, '102'); ?></div>
    <div class="alignright"><?php next_post_link('%link &raquo;','Next in '.$cat_name,TRUE, '102') ?></div>

    - Slacker
    http://www.theslackermethod.com

Topic Closed

This topic has been closed to new replies.

About this Topic