The following code gives you the ability to use [facebook_title]
shortcode in the title and [facebook_description]
respectively.
If you use Yoast SEOany of Yoast SEO, SEOPress or All in One SEO Pack plugins, add these shortcodes alsoprimarily there.
Remove lines activating shortcodes in unused plugins.
// get your special title
function my_facebook_title() {
return get_post_meta( get_the_ID(), 'post_meta_facebook_title', true );
}
// get your special description
function my_facebook_description() {
return get_post_meta( get_the_ID(), 'post_meta_facebook_description', true );
}
// add hooks to shortcodes
add_shortcode( 'listing_title', 'my_facebook_title' );
add_shortcode( 'listing_description', 'my_facebook_description' );
//
// activate shortcode in the post headline
add_filter( 'the_title', 'do_shortcode' );
// activate shortcode for the single post <title>
add_filter( 'single_post_title', 'do_shortcode' );
//// Plugins (optional)
// activate shortcodeshortcodes in YoastSEOPress
add_filter( SEO'seopress_titles_title', title'do_shortcode' );
add_filter( 'wpseo_title''seopress_titles_desc', 'do_shortcode' );
// modifyactivate shortcodes in Yoast SEO title
add_filter( 'wpseo_title', 'my_facebook_title''do_shortcode' );
add_filter( 'wpseo_metadesc', 'do_shortcode' );
//
// activate shortcodeshortcodes in YoastAll in One SEO descriptionPack
add_filter( 'wpseo_metadesc''aioseop_title', 'do_shortcode' );
// modify Yoast SEO description
add_filter( 'wpseo_metadesc''aioseop_description', 'my_facebook_description''do_shortcode' );
Update: SEOPress and All in One SEO Pack support added.