Support

Account

Home Forums General Issues ACF for Open Graph Image Reply To: ACF for Open Graph Image

  • $page->ID is never set and $post->ID has no value inside of your function.

    
    add_action('wp_head', 'rjrasmussen_brand', 5);
    function rjrasmussen_brand( ) {
        // If it's not a taxonomy, die.
        if ( !is_tax('brands') ) {
            return;
        }
        global $post;
        if (get_field('featured_image', $post->ID)) {
            $image = base_image_url(get_field('featured_image', $post->ID), null); 
        }
        echo '<meta property="og:image" content="'.$image.'" />';
    }