• Resolved Paresh Sojitra

    (@pareshsojitra)


    I have tried “wpseo_opengraph_type”, “wpseo_opengraph_url” which is working fine. But the following code to remove opengraph image is not working.

    // Remove Yoast opengraph image
    function remove_yoast_og_image( $myfilter ) {
    
    	if( is_page( 'about' ) || is_tax('taxonomy') ) {
    		return false;
    	}
    	return $myfilter;
    }
    add_filter( 'wpseo_opengraph_image', 'remove_yoast_og_image', 10, 1 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support devnihil

    (@devnihil)

    @pareshsojitra We’re sorry but unfortunately we can’t offer support on custom code. Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes.

    Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview. Thank you for your understanding.

    You can find the developer documentation for customizing the metadata that is output by Yoast SEO here.

    Plugin Support devnihil

    (@devnihil)

    @pareshsojitra Regarding the wpseo_opengraph_image filter, if you are wanting to remove the og:image from being output, you can find some example code to utilize wpseo_frontend_presentation to filter the plugin’s metadata output here.

    I was able to successfully remove the og:image from being output with the following:

    add_filter( 'wpseo_frontend_presenter_classes', 'filter_presenters' );
    
    function filter_presenters( $filter ) {
      if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Image_Presenter', $filter)) !== false) {
    		unset($filter[$key]);
    	}
    	return $filter;
    }
    Thread Starter Paresh Sojitra

    (@pareshsojitra)

    Thank you, I will try this solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wpseo_opengraph_image filter is not Working’ is closed to new replies.