Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Options for Jetpack's Related Posts module
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.