• Resolved Ryan Bickett

    (@rbickett)


    I am currently using the below code to display the Shareaholic, Jetpack Related Posts, and PubExchange below the entry content in a specific order. I am currently using Genesis Simple Hooks to do this, but would prefer to add the code to my functions.php file. I would also like to ensure that this content only shows up on the single post pages.

    <?php echo do_shortcode ('[shareaholic app="share_buttons" id="XXXXXXXX"]'); ?>
    <?php
    if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
        echo do_shortcode( '[jetpack-related-posts]' );
    }
    ?>
    <div id="pubexchange_below_content"></div>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    This should do it:

    add_filter( 'the_content', 'my_the_content_filter' );
    function my_the_content_filter( $content ) {
    
        // Set new content to empty string; so as to not interfere with other content areas (i.e. if is not single)
        $new_content = '';
    
        // Only run on single pages
        if ( is_single() ) {
    
            // Append Shareaholic
            $new_content .= do_shortcode ('[shareaholic app="share_buttons" id="XXXXXXXX"]');
    
            if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
    
    	    // Append Jetpack Related Posts
    	    $new_content .=  do_shortcode( '[jetpack-related-posts]' );
    	}
    
            // Append PubExchange
            $new_content .= '<div id="pubexchange_below_content"></div>';
        }
    
        // Return content (plus appended values, if exists)
        return $content . $new_content;
    }

    That’s off top of my head, lemme know if it doesn’t work.

    Thread Starter Ryan Bickett

    (@rbickett)

    Thank you!

    You’re most welcome.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add PHP & HTML Code to Single Post Pages via genesis_entry_content Hook’ is closed to new replies.