• Resolved marybars

    (@marybars)


    Hello!
    I’m using the GeneratePress Free Theme. I need to place the share buttons in the single post (this share buttons). I used the Code Snippets plugin recommended by the developers and the “generate_after_entry_header” hook. As a result, a button block is displayed not only in the single post page, but also on the homepage (all posts in my settings). I’m just a user, not a programmer and I don’t understand Java script. Please help me find the error in this code:

    add_action( 'generate_after_entry_header', 'ya_sh');
    function ya_sh () {?>
    	<script src="https://yastatic.net/es5-shims/0.0.2/es5-shims.min.js"></script>
    	<script src="https://yastatic.net/share2/share.js"></script>
    	<div class="ya-share2" data-services="vkontakte,odnoklassniki,facebook,twitter,viber,telegram,whatsapp,skype,collections,lj,tumblr,moimir,pocket,blogger,evernote" data-limit="6"></div>
    <?php }
    • This topic was modified 5 years, 11 months ago by marybars.
    • This topic was modified 5 years, 11 months ago by marybars.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    – Can you link me to the page in question?

    – What is the actual issue? That you want it to display in single posts only?

    Thread Starter marybars

    (@marybars)

    Yes, I want to display share-block in single posts only!
    My test site, homepage: https://vrsamoilov.ru/

    I would like the buttons to display like breadcrumbs (only in the single post page):
    Single post example

    Try this instead:

    add_action( 'generate_after_entry_header', 'ya_sh');
    function ya_sh () {
        if ( is_single() ) { ?>
            <script src="https://yastatic.net/es5-shims/0.0.2/es5-shims.min.js"></script>
            <script src="https://yastatic.net/share2/share.js"></script>
            <div class="ya-share2" data-services="vkontakte,odnoklassniki,facebook,twitter,viber,telegram,whatsapp,skype,collections,lj,tumblr,moimir,pocket,blogger,evernote" data-limit="6"></div>
        <?php } 
    }
    Thread Starter marybars

    (@marybars)

    It worked! Thanks a lot!

    No problem 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘problem with displaying a share buttons block’ is closed to new replies.