• I am using the code below to add FB Open Graph Meta Tags (trimmed to just show the description line. It all works apart from the description, which returns a blank string from the ‘get_the_excerpt()’.

    //Lets add Open Graph Meta Info
    function insert_fb_in_head() {
    	global $post;
    	if ( !is_singular()) //if it is not a post or a page
    		return;
    	echo '<meta property="og:description" content="' .get_the_excerpt(). '"/>';
    }
    add_action( 'wp_head', 'insert_fb_in_head', 5 );

    Has anyone come across this before? Any help would be greatly appreciated.

    Thanks

    Jamie

Viewing 1 replies (of 1 total)
  • Thread Starter wright_jamie

    (@wright_jamie)

    I just managed to solve this by increasing the priority from 5 to 20. Any ideas why this would be the case? the_title(), the_categories etc work fine.

Viewing 1 replies (of 1 total)
  • The topic ‘get_the_excerpt not working in header’ is closed to new replies.