• Hi,

    I’m trying to echo the category name with the next_posts_link but I can’t find out how.

    My current code looks like this :
    next_posts_link('More Posts » ');
    I want it to be more like
    next_posts_link('More "Category Name" Posts » ');

    Looking forward to your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • if you are using it in category.php,
    try:

    <?php
    $cat = get_category(get_query_var('cat'))->name;
    next_posts_link('More "'.$cat.'" Posts &raquo; ');
    ?>

    else, if you are using it in index.php or archive.php,
    try:

    <?php if( is_category() ) { $cat = get_category(get_query_var('cat'))->name; next_posts_link('More "'.$cat.'" Posts &raquo; '); } else { next_posts_link('More Posts &raquo; '); ?>

    Thread Starter eggroup

    (@eggroup)

    Thank you so much!

    It’s work. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using category name with next_posts_link’ is closed to new replies.