How to insert another plugin before the Jetpack sharing buttons

Jetpack sharing buttons are added immediately after the post content. In some cases, you may want to insert a new element between your post content and the sharing buttons. To control whether that element will appear before or after the Jetpack sharing buttons, you will have to change the priority of the filter. In the example below, we’ve added an author box and used the priority 18. As long as the priority is less than 19, it will appear before the sharing buttons.
<?php
/**
* When hooked to either the_content or the_excerpt filters,
* this should append the contents of the `author-box.php`
* file in your theme before the Jetpack ShareDaddy contents
* is added, so long as the priority is 18 or less!
* (as ShareDaddy's sharing options go in at priority 19)
*
* @param string $content The post content as passed to the function
* @returns string The content with the author box appended to it.
*/
function my_author_box( $content = '' ) {
ob_start();
get_template_part( 'author', 'box' );
$author_box = ob_get_clean();
return $content . $author_box;
}
add_filter( 'the_content', 'my_author_box', 18 );

Entdecke die Vorteile von Jetpack

Erfahre, wie Jetpack deine WordPress-Website schützen, beschleunigen und beim Wachstum unterstützen kann.

Tarife entdecken

Hast du eine Frage?

Kommentare sind für diesen Artikel geschlossen, aber wir helfen dir trotzdem gerne weiter! Besuche das Support-Forum – wir beantworten dort gerne deine Fragen.

Support-Forum anzeigen