• Resolved pmgopal

    (@pmgopal)


    Hi, I am using [shared_counts] shortcode in a wordpress archive/category page template. However, it seems that the links on the social media icons point to one of the posts on the page rather than the permalink of the category page.

    Could you let me know if there is a way to include the shared counts on a wordpress archive page template.

    Thanks.
    Madan

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    Shared Counts is designed to run on singular content (posts and pages). The share counts are stored as post metadata.

    When used on an archive page, it assumes you want to display share buttons for the current post in the loop, not the archive page itself.

    Unfortunately the shortcode does not support displaying share buttons for arbitrary URLs. But if you’re comfortable editing your theme’s code, you can use the following in your archive.php or category.php file:

    
    if( function_exists( 'shared_counts' ) && is_category() ) {
    	shared_counts()->front->display( 'archive', true, false, get_term_link( get_queried_object(), 'category' );
    }
    
    • This reply was modified 5 years, 8 months ago by Bill Erickson.
    Thread Starter pmgopal

    (@pmgopal)

    Thanks Bill. I will try out the code snippet.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using shortcode in an archive page’ is closed to new replies.