|
<?php |
|
/* |
|
* Remove Jetpack related posts |
|
* Description: Add the functions and filters below to your funcions.php to remove related posts from its default position and change the headline |
|
* Author: Tatiane Pires |
|
* Author URI: http://tatianepires.com.br |
|
* Version: 1.0 |
|
*/ |
|
|
|
/* |
|
* This program is free software: you can redistribute it and/or modify |
|
* it under the terms of the GNU General Public License as published by |
|
* the Free Software Foundation, either version 2 of the License, or |
|
* (at your option) any later version. |
|
* |
|
* This program is distributed in the hope that it will be useful, |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
* GNU General Public License for more details. |
|
*/ |
|
|
|
/* |
|
* Remove Related Posts from the default position |
|
* It will be added in the right place with a shortcode on single.php |
|
*/ |
|
function tps_remove_jetpack_related_posts() { |
|
if ( class_exists( 'Jetpack_RelatedPosts' ) ) { |
|
$jprp = Jetpack_RelatedPosts::init(); |
|
$callback = array( $jprp, 'filter_add_target_to_dom' ); |
|
remove_filter( 'the_content', $callback, 40 ); |
|
} |
|
} |
|
add_filter( 'wp', 'tps_remove_jetpack_related_posts', 20 ); |
|
|
|
/* |
|
* Optional |
|
* Change the headline |
|
*/ |
|
function tps_change_jetpack_related_posts_headline( $headline ) { |
|
$headline = sprintf( |
|
'<strong class="related-posts-title">%s</strong>', |
|
esc_html( 'Posts relacionados' ) |
|
); |
|
return $headline; |
|
} |
|
add_filter( 'jetpack_relatedposts_filter_headline', 'tps_change_jetpack_related_posts_headline' ); |
|
|
|
/* |
|
* Line to add on single.php: |
|
* if ( class_exists( 'Jetpack_RelatedPosts' ) ) echo do_shortcode( '[jetpack-related-posts]' ); |
|
*/ |
|
|
|
/* |
|
* Reference: https://jetpack.com/support/related-posts/customize-related-posts/ |
|
*/ |
|
?> |