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 the page meta data to find the taxonomy and the images.
    // print the OGP data

    return;
} 

Leave a Comment

tech