Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created February 27, 2015 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/09c68354a3f668b19b57 to your computer and use it in GitHub Desktop.
Save jaredatch/09c68354a3f668b19b57 to your computer and use it in GitHub Desktop.
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