Title: Home og:image missing
Last modified: October 13, 2016

---

# Home og:image missing

 *  Resolved [aisforadam](https://wordpress.org/support/users/aisforadam/)
 * (@aisforadam)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/home-ogimage-missing/)
 * Hi. The og:image is working great on all pages except for the homepage (index.
   php). Currently, its blank:
 * `<meta property="og:image" content="" />`
 * My custom functions are:
 *     ```
       function seo_fallback_image() {
         return wp_get_attachment_url( 635 );
       }
   
       add_filter( 'the_seo_framework_og_image_after_featured', __NAMESPACE__ . '\\seo_fallback_image' );
   
       function seo_page_image( $args = array() ) {
   
         if( is_home() || !has_post_thumbnail() )
           $args['image'] = wp_get_attachment_url( 635 );
   
         $disallowed = array(
           'header',
           'icon',
           'wpmudev-avatars',
         );
   
         $args['disallowed'] = $disallowed;
   
         return $args;
       }
   
       add_filter( 'the_seo_framework_og_image_args', __NAMESPACE__ . '\\seo_page_image' );
       ```
   
 * Is my configuration incorrect? Or is there another setting for the homepage? 
   In the settings, I saw fields for the home description, etc. However, there was
   not a field for featured image.
 * Thanks!
    -  This topic was modified 9 years, 10 months ago by [aisforadam](https://wordpress.org/support/users/aisforadam/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/home-ogimage-missing/#post-8293054)
 * Hi [@aisforadam](https://wordpress.org/support/users/aisforadam/),
 * I’ve been able to replicate your issue.
 * It’s because the function does not run completely on the home page. Therefore,
   the filters never fire.
    This is because of [the empty “post ID”](https://github.com/sybrew/the-seo-framework/blob/4ff3cbb9b45bfa0296bb939010ddae964541fcb2/inc/classes/generate-image.class.php#L68-L72).
   This is probably because your home page is a blog (Page ID 0).
 * I was aught to fix this in an earlier version, but I believe that propagated 
   towards more issues as WordPress core functionality misplaces the global $post
   object a lot (that’s why I created “get_the_real_ID”).
 * Nevertheless, what you should use are the following filters for the home page
   until further notice:
 *     ```
       the_seo_framework_ogimage_output
       the_seo_framework_twitterimage_output
       ```
   
 * An example piece of code (I commented out the namespace’d filters so other less-
   experienced users will benefit from this as well):
    I also added caches and fine-
   tuned some calls for improved performance.
 *     ```
       //add_filter( 'the_seo_framework_og_image_after_featured', __NAMESPACE__ . '\\seo_fallback_image' );
       add_filter( 'the_seo_framework_og_image_after_featured', 'seo_fallback_image' );
       /**
        * wp_get_attachment_url is quite a heavy function.
        * As we run it multiple times, we cache it.
        */
       function seo_fallback_image() {
   
       	static $img = null;
   
       	if ( isset( $img ) )
       		return $img;
   
       	return $img = wp_get_attachment_url( 58 );
       }
   
       //add_filter( 'the_seo_framework_og_image_args', __NAMESPACE__ . '\\seo_page_image' );
       add_filter( 'the_seo_framework_og_image_args', 'seo_page_image' );
       function seo_page_image( $args = array() ) {
   
       	//* I held this for performance improvements.
       	if ( is_home() || ! has_post_thumbnail( $args['post_id'] ) )
       		$args['image'] = seo_fallback_image(); // Could be yournamespace\seo_fallback_image() depending on location of function.
   
       	$args['disallowed'] = array(
       		'header',
       		'icon',
       	//	'wpmudev-avatars', // This has been removed internally in favor for site-icon.
       	);
   
       	return $args;
       }
   
       //add_filter( 'the_seo_framework_ogimage_output', __NAMESPACE__ . '\\seo_homepage_image', 10, 2 );
       //add_filter( 'the_seo_framework_twitterimage_output', __NAMESPACE__ . '\\seo_homepage_image', 10, 2 );
       add_filter( 'the_seo_framework_ogimage_output', 'seo_homepage_image', 10, 2 );
       add_filter( 'the_seo_framework_twitterimage_output', 'seo_homepage_image', 10, 2 );
       /**
        * Filter located in render.class.php
        *
        * @param string $image The found image URL. Already escaped.
        * @param int $page_id The current term, post, page ID.
        */
       function seo_homepage_image( $image = '', $page_id = 0 ) {
   
       	//* You'll need to escape here (sort of)!
       	if ( empty( $page_id ) || ! has_post_thumbnail( $page_id ) )
       		return esc_url( seo_fallback_image() ); // Could be yournamespace\seo_fallback_image() depending on location of function.
   
       	return $image;
       }
       ```
   
 * I hope this helps! Best of luck 🙂
    -  This reply was modified 9 years, 10 months ago by [Sybre Waaijer](https://wordpress.org/support/users/cybr/).
 *  Thread Starter [aisforadam](https://wordpress.org/support/users/aisforadam/)
 * (@aisforadam)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/home-ogimage-missing/#post-8299504)
 * That worked. Thanks for the quick reply and example code!
 *  Thread Starter [aisforadam](https://wordpress.org/support/users/aisforadam/)
 * (@aisforadam)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/home-ogimage-missing/#post-8299692)
 * Adding a quick followup note in case somebody else runs across this thread. The
   twitter:card meta needed to be adjusted if wanting a setting other than the default‘
   summary’.
 *     ```
       function seo_homepage_twitter_card( $card ) {
         return 'summary_large_image';
       }
   
       add_filter( 'the_seo_framework_twittercard_output', 'seo_homepage_twitter_card', 10, 2 );
       ```
   
 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/home-ogimage-missing/#post-8299858)
 * These forums really needs a like button.
    Great catch [@aisforadam](https://wordpress.org/support/users/aisforadam/)!
   Cheers 😀
 * P.S. WordPress 4.5’s [Theme/Site Logo](https://codex.wordpress.org/Theme_Logo)
   setting will be added in TSF 2.8.0 as a new fallback image.
    -  This reply was modified 9 years, 10 months ago by [Sybre Waaijer](https://wordpress.org/support/users/cybr/).
    -  This reply was modified 9 years, 10 months ago by [Sybre Waaijer](https://wordpress.org/support/users/cybr/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Home og:image missing’ is closed to new replies.

 * ![](https://ps.w.org/autodescription/assets/icon.svg?rev=3000376)
 * [The SEO Framework – Fast, Automated, Effortless.](https://wordpress.org/plugins/autodescription/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autodescription/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autodescription/)
 * [Active Topics](https://wordpress.org/support/plugin/autodescription/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autodescription/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autodescription/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/home-ogimage-missing/#post-8299858)
 * Status: resolved