Skip to content

Instantly share code, notes, and snippets.

@mintplugins
Last active August 29, 2015 14:22
Show Gist options
  • Save mintplugins/34976827e7e435f0c49d to your computer and use it in GitHub Desktop.
Save mintplugins/34976827e7e435f0c49d to your computer and use it in GitHub Desktop.
PostGrid: How to use featured image instead of permalink on postgrid page
/**
* Filter the permalink for a postgrid posts if it is a custom post type
*
* @since 1.5.0
*
* @param string $permalink The permalink for the post in question
* @param int $grid_post_id The post ID in question.
* @param int $brick_id The Brick ID containing the post grid
*/
function my_custom_permalinks_for_postgrid( $permalink, $grid_post_id, $brick_id ){
global $wp_query;
//If this page is the page with the postgrid on it
if ( $brick_id == '4188' ){
$featured_image = mp_core_the_featured_image( $grid_post_id, "1000" );
//If there is a featured image for this post
if ( !empty( $featured_image ) ){
//Use the post's featured image as the permalink at 1000pixels width
return $featured_image;
}
//If this post doesn't have a featured image
else{
//Use the normal permalink
return $permalink;
}
}
//Otherwise, if it is not the page with the postgrid on it
else{
//Use the normal permalink
return $permalink;
}
}
add_filter( 'mp_stacks_postgrid_grid_post_permalink', 'my_custom_permalinks_for_postgrid', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment