Open graph metadata isn’t pulled on Facebook until after I run that specific link through the debugger

First, this isn’t a WordPress specific question, it’s a Facebook question. Secondly, Facebook caches pages, they don’t crawl them on every submission. If you have a URL that has already been submitted to Facebook before, then they will have already crawled it for the OG data once before, and saved it to their cache. If … Read more

sharing video on facebook from wordpress

That really depends on how the video is embedded into the page. Facebook can only handle specific formats and if it sees something it doesn’t expect, it defaults to a failsafe “show nothing” standard. If the embedded video is well-recognized standard (i.e. YouTube’s default player) it should work just fine. If it’s your own self-hosted … Read more

Generating the ogp tags in theme

If it is a page the global post object is already set when wp_head fires. But you have to get the data for this page with custom code. Pseudo code: add_action ( ‘wp_head’, ‘wpse_58539_get_ogp’ ); function wpse_58539_get_ogp() { if ( ! is_page_template( ‘your-template-name’ ) ) { return; } $page = get_post( $GLOBALS[‘post’] ); // Inspect … Read more

How can you upload an image from within a settings page?

WordPress provides a convenient function for just this purpose: wp_handle_upload(). Assuming that you already have the appropriate file form field in your settings page, and that you’re using register_setting() for your options, and therefore already have an options validation callback, simply handle the file form field data using wp_handle_upload(). Here’s an example: <?php // Validate … Read more

Set Custom Post feature image as og:image

It appears that your site doesn’t use the core WordPress Featured Image feature but instead uses a custom image field (probably from Advanced Custom Fields). Yoast’s plugin, Jetpack, and presumably many others look for the Featured Image image when setting the opengraph meta tag. So you have two options: Use the core Featured Image feature … Read more

Is there a filter to define the OG image on a given post?

The wpseo_opengraph_image filter can only be used to modify the existing og:image. Otherwise, you will need to hook into the wpseo_opengraph action to add a different image. Here’s an example of adding an image from a custom field on the post object (assuming you’re using ACF here). function my_wpseo_opengraph() { global $post; if (isset($post)) { … Read more

How to add code to Header.php in a child theme?

I would hook into the wp_head action. I would place this in a plugin so as to abstract it from your presentation layer. This allows for scalability and changing of themes. This also prevents any analytics collateral damage if a step is missed in migration from one theme to the next. add_action(‘wp_head’, ‘wpse_43672_wp_head’); function wpse_43672_wp_head(){ … Read more