• Hi,

    Is it possible to override the Open Graph tags?

    For example on a WooCommerce category page I want to add in the category image for the og:image tag, currently that tag is blank.

    I tried adding og:image to the head but then it shows 2 og:image tags which is confusing things.

    Thanks
    Shaun

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Shaun,

    More options for Terms & Taxonomies are planned, but that will take awhile.

    Until then, you could use the following filter in the meantime:

    
    /**
     * Filters default image arguments for TSF.
     *
     * @param array $defaults The image defaults.
     * @param array $args     The image callback arguments.
     */
    add_filter( 'the_seo_framework_og_image_args', function( $defaults, $args = array() ) {
    
    	if ( function_exists( 'is_product_category' ) ) {
    		if ( is_product_category( 'tshirts' ) ) {
    			$defaults['image'] = 'http://example.com/path/to/my/image.jpg';
    		} elseif ( is_product_category( 'caps' ) ) {
    			$defaults['image'] = 'http://example.com/path/to/my/image.jpg';
    		}
    	}
    
    	return $defaults;
    }, 10, 2 );
Viewing 1 replies (of 1 total)

The topic ‘Override Open Graph tags?’ is closed to new replies.