Home › Forums › Support › Creating a shortcode with yoast This topic has 5 replies, 2 voices, and was last updated 2 years, 7 months ago by Elvin. Viewing 6 posts - 1 through 6 (of 6 total) Author Posts August 10, 2021 at 2:44 pm #1891230 nomadiceman Has anyone created a shortcode to display some of the variables from yoast seo plugin? I’m trying to create a shortcode for the “Estimate time” to read the post echo (string) YoastSEO()->meta->for_current_page()->estimated_reading_time_minutes, " minutes"; Anyone done something similar? August 10, 2021 at 5:38 pm #1891293 ElvinStaff Customer Support Hi there, I believe this can help you in creating shortcodes. https://docs.generatepress.com/article/creating-a-shortcode/ So for example: add_shortcode( 'yoast_estimate_time', function() { ob_start(); // Start your PHP below echo (string) YoastSEO()->meta->for_current_page()->estimated_reading_time_minutes, " minutes"; // End your PHP above return ob_get_clean(); } ); Replacing (string) on the echo line with your text wrapping in '' With this PHP snippet, you can use [yoast_estimate_time]. This is assumes the line you’ve provided is correct. August 10, 2021 at 5:56 pm #1891298 nomadiceman This is awesome I understand everything apart from what I need to put in the (string) August 10, 2021 at 6:10 pm #1891304 ElvinStaff Customer Support Ah it’s for making the output coming from YoastSEO().. into string characters. You can keep it that way. August 10, 2021 at 6:42 pm #1891323 nomadiceman thank you! I will give that a try August 10, 2021 at 9:36 pm #1891405 ElvinStaff Customer Support No problem. Let us know how it goes. 😀 Author Posts Viewing 6 posts - 1 through 6 (of 6 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In