• Resolved NIkesh Kr Yadav

    (@nikeshyadav)


    hi i am using
    <?php next_post_link( '%link class="prev" ', '<span></span> Previous Article', FALSE, '27 and 18 and 19 and 20 and 21 and 14' ); ?>
    and its output is <a href="http://example.com/adfasdfa-1/" rel="prev"><span></span> Next Article</a>

    in this i want to remove rel="prev" and wants to add class=”prev”

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You could hook the filter ‘next_post_link’. Your hook function is passed the output string from your next_post_link() function call. You can use basic string operations to alter it as needed. Whatever you return is directly echoed out to the user’s browser.

    Thread Starter NIkesh Kr Yadav

    (@nikeshyadav)

    Thanks for help i have solved it as

    function add_class_next_post_link($html){
        $html = str_replace('<a','<a class="prev"',$html);
        return $html;
    }
    add_filter('next_post_link','add_class_next_post_link',10,1);
    function add_class_previous_post_link($html){
        $html = str_replace('<a','<a class="next"',$html);
        return $html;
    }
    add_filter('previous_post_link','add_class_previous_post_link',10,1);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove rel from next_post_link’ is closed to new replies.