Hi Jeff, thanks for such a fast reply on Saturday night. Workaholics we are ??
Yes, I tried doing something like below code as add on function for a shortcode like [year] to dynamically display this year’s value. Work in post title and content and widgets but can’t get it working in places like post excerpt and in meta (using Autodescription for SEO plugin).
Probably not in the scope of your plugin and I do apologize for that and bothering you on the weekend on top of my other sins.
Though would it be possible to add my custom function shortcodes in your meta fields or others I make in this plugin?
Since you can do a shortcodes and plugins I am kinda hoping you’d be able to point me to the right solution, if you don’t mind me asking. Thanks anyway and wish you a happy relaxing Sunday…
What I use that is not working for excerpt and SEO Meta fields:
//* Activate shortcode function in Post Title
add_filter( ‘the_title’, ‘do_shortcode’ );
//* Enable Post Meta Shortcode Support
add_filter( ‘single_post_title’, ‘do_shortcode’ );
// Enable shortcodes in text widgets
add_filter(‘widget_text’, ‘do_shortcode’);
// Enable shortcodes in post excerpt
add_filter(‘get_the_excerpt’, ‘do_shortcode’);
//* Activate shortcode function in SEO Autodescription plugin Title and Meta Description
add_filter( ‘autodescription_title’, ‘do_shortcode’ );
add_filter( ‘autodescription_description’, ‘do_shortcode’ );
//* and in Autodescription OG and Twitter titles and descriptions
add_filter( ‘autodescription_og_title’, ‘do_shortcode’ );
add_filter( ‘autodescription_og_description’, ‘do_shortcode’ );
add_filter( ‘autodescription_twitter_title’, ‘do_shortcode’ );
add_filter( ‘autodescription_twitter_description’, ‘do_shortcode’ );
//* Shortcode to DYNAMICALLY display the CURRENT year
//* shortcode: [year]
add_shortcode( ‘year’ , ‘current_year’ );
function current_year() {
$year = date(“Y”);
return “$year”;
}