Created
April 27, 2016 13:34
-
-
Save mintplugins/c0c419c463ebc5ff34959691cc50a3ae to your computer and use it in GitHub Desktop.
Make your posts in your PostGrid link to any URL in a custom field you choose
This file contains hidden or 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
function my_custom_field_links_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 == '31981' ){ | |
$site_link = get_post_meta( $grid_post_id, 'your_custom_field_slug', true ); | |
//If there is a site link | |
if ( !empty( $site_link ) ){ | |
return $site_link; | |
} | |
//If there is not a site link in the body | |
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_field_links_for_postgrid', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment