This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set Jetpack related posts image size | |
* | |
* @since 1.0.0 | |
* @param array $thumbnail_size | |
* @return array | |
*/ | |
function ja_jetpack_related_posts_size ( $thumbnail_size ) { | |
$thumbnail_size['width'] = 140; | |
$thumbnail_size['height'] = 140; | |
$thumbnail_size['crop'] = true; | |
return $thumbnail_size; | |
} | |
add_filter( 'jetpack_relatedposts_filter_thumbnail_size', 'ja_jetpack_related_posts_size' ); | |
/** | |
* Set Jetpack related posts count | |
* | |
* @since 1.0.0 | |
* @param array $options | |
* @return array | |
*/ | |
function ja_jetpack_related_posts_count( $options ) { | |
$options['size'] = 4; | |
return $options; | |
} | |
add_filter( 'jetpack_relatedposts_filter_options', 'ja_jetpack_related_posts_count' ); | |
/** | |
* Remove default placement of Jetpack related posts. | |
* | |
* For manual placment use do_shortcode( '[jetpack-related-posts]' ); | |
* | |
* @since 1.0.0 | |
*/ | |
function ja_jetpack_related_posts_placement() { | |
if ( class_exists( 'Jetpack_RelatedPosts' ) ) : | |
$jprp = Jetpack_RelatedPosts::init(); | |
$callback = array( $jprp, 'filter_add_target_to_dom' ); | |
remove_filter( 'the_content', $callback, 40 ); | |
endif; | |
} | |
add_filter( 'wp', 'ja_jetpack_related_posts_placement', 20 ); |
Questions, comments, or suggestion for improvement? Leave a comment on the GitHub Gist page.