• Resolved politicske

    (@politicske)


    Hello Tom/Leo. I have this custom social share plugin which is hooked inside content by the plugin author and was showing its HTML content in the beginning and end of schema content. I had to choose the manual placement and hook it like below to show before content and after content. However, I was wondering if you have a better idea of a code to open and close the ‘before and after entry content’ loop other than what I am doing below. Thank you.

    // social sharing buttons before the content
    add_action( 'generate_before_content', 'as_custom_share_buttons');
    function as_custom_share_buttons() {
         if (is_single() ) {
        ?>
    <?php echo do_shortcode('[share_buttons]'); ?>
    <?php
     }
    }
    
    // social sharing buttons after content
    add_action( 'generate_after_content', 'as_custom_share_button');
    function as_custom_share_button() {
         if (is_single() ) {
        ?>
    <?php echo do_shortcode('[share_buttons]'); ?>
    <?php
     }
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    That looks ok to me – are they not working, or do you want them to show up somewhere else?

    Let me know ??

    Thread Starter politicske

    (@politicske)

    It is working. Just thought there was a simpler code for it rather than creating two shortcodes. Thanks.

    Theme Author Tom

    (@edge22)

    You could do this:

    add_action( 'generate_before_content', 'as_custom_share_buttons');
    add_action( 'generate_after_content', 'as_custom_share_buttons');
    
    function as_custom_share_buttons() {
        if ( is_single() ) {
            echo do_shortcode( '[share_buttons]' );
        }
    }
    Thread Starter politicske

    (@politicske)

    Thanks. It worked.

    Theme Author Tom

    (@edge22)

    You’re welcome ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Code Assistance’ is closed to new replies.