Home Forums Front-end Issues Display social buttons after custom fields


Display social buttons after custom fields

  • Hello and thank you for your great work.

    I use last version ACF Pro and have some issue with plugins for displaying social buttons after content. All of them display social buttons before custom fields. That is buttons display in the middle of content (immediately after <?php the_content(); ?> part, but before custom fields). Is it possible to fix it without editing code of these plugins? Can you help me please to fix this issue?

  • Most of these plugins add their output by adding a filter to “the_content”. Some of these plugins give alternate ways of adding their output so that you can place it where you want, some don’t. That would depend on the plugin and you’d need to check the plugin or with the plugin author.

    Your other choices are to add your own filter to “the_content” that runs at a lower priority than theirs or to not use the_content() to display the content of the page and run the filter yourself.

    // option 1 - add filter to the_content
    // low priority so it runs before other filters
    // you'll probably need to adjust the priority to get it to work
    add_filter('the_content', 'my_content_filter', 1);
    function my_content_filter($content) {
      // generate your content and add it to $content
      $content .= 'whatever content you generated';
      return $content;
    // option 2, run the_content filter yourself
    $content = $post->post_content;
    // generate your content and add it to $content
    $content .= 'whatever content you generated';
    apply_filters('the_content', $content);

    But the best bet is to look at the other plugin and find a way to alter what it’s doing using whatever filters or functions that they provide.

  • The easiest way for me was to place social buttons in the widget.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Display social buttons after custom fields’ is closed to new replies.