Created
February 27, 2015 23:26
-
-
Save jaredatch/09c68354a3f668b19b57 to your computer and use it in GitHub Desktop.
Options for Jetpack's Related Posts module
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment