以下代码使您能够使用[facebook_title]
标题中的短代码和[facebook_description]
分别地
如果您使用任何一个EAST SEO、SEOPress或All-in-One SEO Pack插件,请主要在此处添加这些短代码。
删除未使用插件中激活短代码的行。
// 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 shortcodes in SEOPress
add_filter( \'seopress_titles_title\', \'do_shortcode\' );
add_filter( \'seopress_titles_desc\', \'do_shortcode\' );
// activate shortcodes in Yoast SEO
add_filter( \'wpseo_title\', \'do_shortcode\' );
add_filter( \'wpseo_metadesc\', \'do_shortcode\' );
// activate shortcodes in All in One SEO Pack
add_filter( \'aioseop_title\', \'do_shortcode\' );
add_filter( \'aioseop_description\', \'do_shortcode\' );
Update: 添加了SEOPress和多合一SEO包支持。