Skip to main content
More plugin support added
Source Link
Max Yudin
  • 6.4k
  • 2
  • 25
  • 36

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.

The following code gives you the ability to use [facebook_title] shortcode in the title and [facebook_description] respectively.

If you use Yoast SEO, add these shortcodes also there.

// 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' );

//
// activate shortcode in Yoast SEO title
add_filter( 'wpseo_title', 'do_shortcode' );

// modify Yoast SEO title
add_filter( 'wpseo_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO description
add_filter( 'wpseo_metadesc', 'do_shortcode' );
 
// modify Yoast SEO description
add_filter( 'wpseo_metadesc', 'my_facebook_description' );

The following code gives you the ability to use [facebook_title] shortcode in the title and [facebook_description] respectively.

If you use any of Yoast SEO, SEOPress or All in One SEO Pack plugins, add these shortcodes primarily 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 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 and All in One SEO Pack support added.

added 11 characters in body
Source Link
Max Yudin
  • 6.4k
  • 2
  • 25
  • 36

The following code gives you the ability to use [facebook_title] shortcode in the title and [facebook_description] respectively.

If you use Yoast SEO, add these shortcodes also there.

// 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' );

// modifyactivate shortcode for the single post <title>
add_filter( 'single_post_title', 'my_facebook_title''do_shortcode' );

//
// activate shortcode in Yoast SEO title
add_filter( 'wpseo_title', 'do_shortcode' );

// modify Yoast SEO title
add_filter( 'wpseo_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO description
add_filter( 'wpseo_metadesc', 'do_shortcode' );

// modify Yoast SEO description
add_filter( 'wpseo_metadesc', 'my_facebook_description' );

The following code gives you the ability to use [facebook_title] shortcode in the title and [facebook_description] respectively.

If you use Yoast SEO, add these shortcodes also there.

// 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' );

// modify the single post <title>
add_filter( 'single_post_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO title
add_filter( 'wpseo_title', 'do_shortcode' );

// modify Yoast SEO title
add_filter( 'wpseo_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO description
add_filter( 'wpseo_metadesc', 'do_shortcode' );

// modify Yoast SEO description
add_filter( 'wpseo_metadesc', 'my_facebook_description' );

The following code gives you the ability to use [facebook_title] shortcode in the title and [facebook_description] respectively.

If you use Yoast SEO, add these shortcodes also there.

// 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' );

//
// activate shortcode in Yoast SEO title
add_filter( 'wpseo_title', 'do_shortcode' );

// modify Yoast SEO title
add_filter( 'wpseo_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO description
add_filter( 'wpseo_metadesc', 'do_shortcode' );

// modify Yoast SEO description
add_filter( 'wpseo_metadesc', 'my_facebook_description' );
Post Undeleted by Max Yudin
Post Deleted by Max Yudin
Source Link
Max Yudin
  • 6.4k
  • 2
  • 25
  • 36

The following code gives you the ability to use [facebook_title] shortcode in the title and [facebook_description] respectively.

If you use Yoast SEO, add these shortcodes also there.

// 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' );

// modify the single post <title>
add_filter( 'single_post_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO title
add_filter( 'wpseo_title', 'do_shortcode' );

// modify Yoast SEO title
add_filter( 'wpseo_title', 'my_facebook_title' );

//
// activate shortcode in Yoast SEO description
add_filter( 'wpseo_metadesc', 'do_shortcode' );

// modify Yoast SEO description
add_filter( 'wpseo_metadesc', 'my_facebook_description' );