Site logo

Archived topic

Elements template tags

7 replies · Started by tobymiguel on March 26, 2019

Viewing posts 1–8 of 8

I have two problems with elements template tags I hope you can help with.

I use this function made by tom to display number of comments in the header:

add_shortcode( 'comment_number', 'tu_comment_number_sc' );
function tu_comment_number_sc() {
    ob_start();
    comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
    return ob_get_clean();
}

The problem is that it links to #respond or #comments, and when I click the link nothing happens. It does not go to the comment section. I am using Disqus with Disqus Conditional Load plugin, I am not sure if this is why or if it is possible to fix. Even after making sure comments are loaded it doesn't work.

Next thing is when I use {{post_author}}, it will link to the Author archive. Is it possible to disable this?

Thank you so much, I really love this theme and the support I get here

Hi there,

any chance you can link us to the site? You can edit your original topic and use the Site URL field for privacy. Not sure on the first issue as its not using the standard comments but we can look.

The author link we can disable with some CSS

Hey David

I edited my answer with an example url :)

Hi there,

You could try this:

add_filter( 'respond_link', function() {
    return get_permalink() . '#disqus_thread';
} );

add_filter( 'get_comments_link', function() {
    return get_permalink() . '#disqus_thread';
} );

Let me know :)

Hi Tom

It works if there are no comments, if there is more than 0 comments the link doesn't change :-)

Also, was it possible to disable the Author archive link when using {{post_author}} :)

Just updated the code above.

As for the post author, try this:

add_filter( 'generate_page_hero_post_author', function() {
    global $post;
    $author_id = $post->post_author;

    return sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%s</span></span>',
        esc_html( get_the_author_meta( 'display_name', $author_id ) )
    );
} );

Perfect !

Awesome :)

This archived topic is closed to new replies.