Last active
October 10, 2018 01:18
-
-
Save srikat/70d1ac89b4efabe3d7ec to your computer and use it in GitHub Desktop.
JetPack Related Posts Customizations. https://sridharkatakam.com/jetpack-related-posts-customizations/
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
// change thumbnail size | |
function jetpackchange_image_size ( $thumbnail_size ) { | |
$thumbnail_size['width'] = 350; | |
$thumbnail_size['height'] = 200; | |
// $thumbnail_size['crop'] = true; | |
return $thumbnail_size; | |
} | |
add_filter( 'jetpack_relatedposts_filter_thumbnail_size', 'jetpackchange_image_size' ); |
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
// Remove JP Related Posts from its default location | |
function jetpackme_remove_rp() { | |
$jprp = Jetpack_RelatedPosts::init(); | |
$callback = array( $jprp, 'filter_add_target_to_dom' ); | |
remove_filter( 'the_content', $callback, 40 ); | |
} | |
add_filter( 'wp', 'jetpackme_remove_rp', 20 ); |
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
add_filter( 'jetpack_relatedposts_post_category_context', 'sk_customize_jp_context', 10, 2 ); | |
function sk_customize_jp_context( $post_cat_context, $category ) { | |
$post_cat_context = sprintf( | |
// _x( 'In "%s"', 'in {category/tag name}', 'jetpack' ), /* Default */ | |
_x( '%s', 'in {category/tag name}', 'jetpack' ), | |
$category->name | |
); | |
return $post_cat_context; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using the first snippet of code (gistfile1.php): how can I tell Jetpack to crop the feature images by 300x300px starting from the top left of the image?
I've used this, to no avail:
function jetpackchange_image_size ( $thumbnail_size ) { $thumbnail_size['width'] = 300; $thumbnail_size['height'] = 300; $thumbnail_size['crop'] = array( 'left', 'top'); return $thumbnail_size;