Sharing buttons disappear if I use 'the_content' filter
-
Hi I am building this touring website: uniquecorners.com
I have a custom post type called ‘tour’.
In order to print it, I use a class that has all the variables needed to print and that takes a WP_post in the __construct function.The construc function looks like:
function __construct ($reference_post){ if(is_numeric($reference_post)): $reference_post=get_post($reference_post); endif; if ($reference_post instanceof WP_Post): $this->ID= $reference_post->ID; $this->title = apply_filters( 'the_title', $reference_post->post_title, $reference_post->ID ); $this->content = apply_filters( 'the_content', $reference_post->post_content ); $this->excerpt = $reference_post->post_excerpt; //$this->excerpt = apply_filters( 'the_excerpt', $reference_post->post_excerpt ); (I don't filter because I don't want sharing buttons there) $this->permalink = get_permalink ( $reference_post ); endif; }
In the home page I list my tours with a
get_posts
call. For each result I creat a new tour object and print it.At the end of the homepage, the sharing buttons don’t appear. I commented code until I found that calling to ‘the_content’ for each tour would, somehow modify ‘the_content’ of the homepage. Thus, not showing sharing buttons.
How can I filter the content and keep the sharing buttons in my homepage?
Thanks!
- The topic ‘Sharing buttons disappear if I use 'the_content' filter’ is closed to new replies.