• Resolved blissyung

    (@blissyung)


    Removing og with filters not working in recent updates

    <meta property=”article:published_time” content=”” />
    <meta property=”article:modified_time” content=”” />
    <meta property=”og:image” content=”” />

    I use to disable them with below filters but they’re not working anymore

    add_filter( ‘wpseo_og_article_published_time’, ‘__return_false’ );
    add_filter( ‘wpseo_og_article_modified_time’, ‘__return_false’ );
    add_filter(‘wpseo_opengraph_image’ , ‘__return_false’ );

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Michael Tiña

    (@mikes41720)

    Hello @blissyung

    Some filters and actions were deprecated since v14.0 of Yoast SEO for WordPress. You can learn more about it and their replacements here — https://developer.yoast.com/customization/yoast-seo/api-filter-actions-deprecations

    Thread Starter blissyung

    (@blissyung)

    I already went through there besides I’m not a developer I’m only looking for a replacement for those filters that would work with the new version Yoast

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We are afraid to say that we no longer have a simple filter to disable the certain parts of the Yoast SEO generated open graph meta. You’ll need to implement the Yoast SEO Presenter by following the steps given in the guide here.

    Thread Starter blissyung

    (@blissyung)

    I visited these pages (https://developer.yoast.com/customization/yoast-seo/api-filter-actions-deprecations/https://developer.yoast.com/blog/yoast-seo-14-0-adding-metadata/ countless times and i couldn’t figure it out that’s why I started this thread. I only know basics of codding as said in my second reply, I think it’s your way of telling me indirectly to get premium so I get support you can’t put those codes here for free users. thanks for your help anyway… AIOSEO didn’t hesitate but provide me codes on their first reply to disable those tags in my other website.

    Please anyone else who can provide those filter codes should kindly reply to this thread thanks.

    • This reply was modified 3 years, 10 months ago by blissyung.
    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We understand your concern and you’d like to get the example code to remove the Yoast SEO generated open graph meta. We hate to tell you that we don’t have an example code for this. However, we have already forwarded this to our development team so they can publish an example code in the developer.yoast.com.

    On the other hand, trust me, even when you buy a premium subscription, we still won’t be able to offer you the relevant example code.

    Thread Starter blissyung

    (@blissyung)

    Found it! you can now mark this as resolved. For anyone else looking for this here you go.

    add_filter(
        'wpseo_frontend_presenter_classes',
        function ( $filter ) {
    
    	if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter', $filter)) !== false) {
    		unset($filter[$key]);
    	}
    
    	return $filter;
        }
    );
    
    add_filter(
        'wpseo_frontend_presenter_classes',
        function ( $filter ) {
    
    	if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Article_Published_Time_Presenter', $filter)) !== false) {
    		unset($filter[$key]);
    	}
    
    	return $filter;
        }
    ); 
    

    Credits: https://wordpress.org/support/topic/filter-for-open-graph-articlepublished_time/

    • This reply was modified 3 years, 10 months ago by blissyung.
    Plugin Support devnihil

    (@devnihil)

    @blissyung Thanks for your reply and for providing the solution that you found. We are going ahead and marking this issue as resolved as per your request. If you require any further assistance please create a new issue.

    @blissyung Thanks a lot! Hope it will last.

    Thread Starter blissyung

    (@blissyung)

    @tizz You’re welcome, glad it worked 😉

    A simpler version:

    add_filter(
        'wpseo_frontend_presenter_classes'
        , function($filter) {
            return array_diff($filter, [
                'Yoast\WP\SEO\Presenters\Open_Graph\Article_Published_Time_Presenter',
                'Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter',
            ]);
        }
    );

    This is PERFECT. After searching high and low, this actually works. Thanks a mil!

    I have used the example that @lev0 has posted, it has removed the dates from meta og when viewing the page via view page source.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Remove og article:published_time/modified_time’ is closed to new replies.