• Resolved gttygrl

    (@gttygrl)


    I’m trying to customize the og:description to pull from a custom meta description field. My code is adding the correct og:description, but it’s not replacing, so the og:desc is also appearing further below, pulling in the post title.

    Sample page:
    https://blogs.getty.edu/iris/getty-voices-our-l-a/

    This is the code I’m using:

    add_filter('fb_og_desc', 'custom_og_description');
    function custom_og_description() {
    	/* Get the current post ID. */
    	$post_id = get_the_ID();
    
    	/* If we have a post ID, proceed. */
    	if ( !empty( $post_id ) ) {
    
    		/* Get the custom post description. */
    		$desc = get_post_meta( $post_id, 'iris_post_metadescription', true );
    
    		/* If a post description was input, change the og description. */
    		if ( !empty( $desc ) )
    			echo "<meta property=\"og:description\" content=\"" . $desc . "\" />\n";
    
    	}
    }
Viewing 1 replies (of 1 total)
  • Thread Starter gttygrl

    (@gttygrl)

    Man, this happens every time. As soon as I hit “submit”, it occurred to me to un-check the “add description” box in the settings. Now I’m just getting the correct one (albeit not in the nice and orderly position of being with the other og: tags).

    Never mind. *sigh*

Viewing 1 replies (of 1 total)
  • The topic ‘fb_og_desc filter is adding, not replacing’ is closed to new replies.