Closed saadmerie closed 7 years ago
Hey, thanks for your suggestion.
It's not really something I would like to integrate into the plugin but I would be happy to help you with this anyway. I created a little snippet for you: It's a new shortcode which gets the custom field value and forwards it to the original shortcode:
/*
* Custom shortcode for a dynamically created shortcode based on the custom field "my_course_id_cf"
*/
add_shortcode( 'my_udemy', function( $atts ) {
$course_id = get_post_meta( get_the_ID(), 'my_course_id_cf', true );
return ( ! empty( $course_id ) ) ? do_shortcode('[ufwp id="' . $course_id . '"]') : null;
});
The code above can be added to the end of the functions.php file of your child-/theme. The name of the shortcode is my_udemy and the custom field key is named my_course_id_cf. Both can be adjusted inside the code. The shortcode will be used as follows:
[my_udemy]
Hope this helps 😃
Thanks really, this look like a working one, I will try it later today
Hello and thanks for the great plugin,
I want to make the shortcode get the ID from a custom field, what is the proper way to do that? also this can be as feature in future, to be added to the free or pro plugin. thanks and regards.