WordPress.org

Support

Support » Plugins and Hacks » display category name in previous/next links

display category name in previous/next links

  • 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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m also looking for the exact same thing, anyone know the answer to this?

    thirdeyetc
    Member

    @thirdeyetc

    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.

    slackermethod
    Member

    @slackermethod

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘display category name in previous/next links’ is closed to new replies.