Ryan Ryan - 2 months ago 15
PHP Question

How do I automatically include PHP in Wordpress excerpt?

How do I automatically include the following PHP script in my WordPress posts?

<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>

I am not familiar with PHP and I have assumed that the above is a code from a plugin I am using to show social sharing buttons.

I was hoping someone may have dealt with adding elements into the excerpt automatically before and would have some code I could copy into my child theme


AddToAny Share Buttons plugin have options Display at the bottom of excerpts or you can add code

function add_excerpt_social( $excerpt ) {
    if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { return $excerpt.ADDTOANY_SHARE_SAVE_KIT(array("output_later" => true)); }
    else { return $excerpt; }
add_filter('get_the_excerpt', 'add_excerpt_social');

to your theme functions.php file.