fb_og_desc filter is adding, not replacing
-
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)
Viewing 1 replies (of 1 total)
- The topic ‘fb_og_desc filter is adding, not replacing’ is closed to new replies.