change #respond into #wp_comments

Community Forums Forums General Discussion change #respond into #wp_comments

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  jennylynn 10 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #73575

    jennylynn
    Participant
    Post count: 31

    Hello,

    How can I change the anchor of the Leave a Comment link at the beginning of the article from #respond to #wp_comments. I installed the Social Comments plugin and it uses the #wp_comments anchor instead of #respond.

    Any help is greatly appreciated!!!

    http://diezmejores.mis-remedios-caseros.com
    #73621

    ccochran
    Member
    Post count: 2

    Hi Jennylynn,

    WordPress includes a filter that allows us to change this link. Place the following code in your child theme’s function.php. This will override #repond to be #wp_comments.

    Let me know if you have any further questions! This should work though.

    
    add_filter( 'get_comments_link', 'sp_forum_comments_link_filter', 10, 2 );
    /**
     * Filter the comments link replacing #repond from 'genesis_comments_link_filter' to #wp_comments 
     * If post has comments, link to #comments div. If no, link to #wp_comments div.
     */
    function sp_forum_comments_link_filter( $link, $post_id ) {
    
    	// No Comments
    	if ( 0 == get_comments_number() )
    		return get_permalink( $post_id ) . '#wp_comments';
    
    	return $link;
    
    }
    
    #73823

    jennylynn
    Participant
    Post count: 31

    Thank you so much!!!! It worked like magic.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.