Search code examples
wordpresswordpress-theming

Wordpress manipulate comment_reply_link() add #nav-comform to the link


I am working on a theme for a friend but get stuck ... The comments and the comment form are inside a jquery tab. To toggle the tab on a klick of the reply link i have to add #nav-comform to the link.

Example:

http://localhost/?p=109&replytocom=10#respond#nav-comform

I know i have to work with a filter in the functions.php but i have never done it before so i am a little lost and everything i try fail ...

I know it should be something like this filter example to add rel="nofollow" to the reply link:

function add_nofollow_to_reply_link( $link ) {
return str_replace( '")\'>', '")\' rel=\'nofollow\'>', $link );
}

add_filter( 'comment_reply_link', 'add_nofollow_to_reply_link' );

Maybe some one can lead me a way ?

Thank you very much !!


Solution

  • Try the following

    function add_link_hash($args){
        $args['respond_id'] = 'nav-comform';
        return $args;
    }
    add_filter('comment_reply_link_args', 'add_link_hash', 10);