How to use wordpress shortcut in meta title and meta description
-
I have created [year] shortcut via the following code
// Add “[year]” shortcode function year_shortcode() { return date('Y'); } add_shortcode('year', 'year_shortcode'); add_filter( 'single_post_title', 'my_shortcode_title' ); add_filter( 'the_title', 'my_shortcode_title' ); function my_shortcode_title( $title ){ return do_shortcode( $title ); }
I tried the following code with no luck.
/** * Allow shortcodes in the Meta Data. */ add_filter( 'rank_math/paper/auto_generated_description/apply_shortcode', '__return_true' );
But the problem is that [year] shortcode is not replaced in meta title and meta description. Please help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to use wordpress shortcut in meta title and meta description’ is closed to new replies.