I want to show post description as meta description on frontend.For this i created custom variable that will show post desction on frontend.
Here is the code which i am using to create custom variable and is working fine:
function retrieve_var1_replacement( $var1 ) {
global $post;
return strip_tags(substr($post->post_content, 0, 150));
}
function register_my_plugin_extra_replacements() {
wpseo_register_var_replacement( '%%mycustomdesc%%', 'retrieve_var1_replacement', 'advanced', 'This is to show post description' );
}
add_action( 'wpseo_register_extra_replacements', 'register_my_plugin_extra_replacements' );
This code working fine on frontend but the issue is that on post page in admin panel, instead of showing description, its show %%mycustomdesc%% in the snippet preview box. It should show the same content that is coming on frontend.
Here is the backend screenshot for better understanding
Anyone can suggest me how i can show description in place of
%%mycustomdesc%%