Last active
April 27, 2021 19:23
-
-
Save pingram3541/6e071e6dccfb00c8119134da75dda98c to your computer and use it in GitHub Desktop.
Mediavine custom Create Recipe Jump-To button using $post_id
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
//Shortcode to output custom Jump-To Recipe button by Create | |
function custom_mvcreate_jumpbutton_func(){ | |
$post_id = get_the_ID(); | |
if( ! function_exists( 'mv_get_post_creations' ) ) | |
return; | |
$recipes = mv_get_post_creations( $post_id ); | |
if( empty( $recipes ) ) | |
return; | |
$recipe = $recipes[0]; //first recipe ID | |
if( ! function_exists( 'mv_create_get_creation' ) ) | |
return; | |
$type_of_card = mv_create_get_creation( $recipe ); | |
return do_shortcode( '[mv_create_jtr id="' . $recipe . '" type="' . $type_of_card->type . '"]' ); | |
} | |
add_shortcode('mv_jump_button', 'custom_mvcreate_jumpbutton_func'); | |
//use: [mv_jump_button] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment