• Resolved Garet H.

    (@pagetopixel)


    Hello, I am using a real estate plugin that generates its own Open Graph data for listings. I want to use your plugin for all pages except the single view for these specific pages. Is there a filter I can add to disable it just on these pages that already have OG data?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Alex MacArthur

    (@alexmacarthur)

    Hi! You bet. You can use the complete_open_graph_all_data filter to do this. On that filter, just check the current post type, or whatever else you want, and return an empty array if you’re on any of those pages. That empty array will be the newly filtered Open Graph data for those pages, which is nothing, so no tags will be generated for that page.

    Example:

    
    add_filter('complete_open_graph_all_data', function ($data) {
         if(get_post_type() === 'real_estate_post_type') return array();
         return $data;
    });
    

    If you have a specific page in mind that you’d like to exclude, you can do that too:

    
    add_filter('complete_open_graph_all_data', function ($data) {
         if(is_page('my-page')) return array();
         return $data;
    });
    

    Let me know if that doesn’t help solve your problem.

    Alex

    Plugin Author Alex MacArthur

    (@alexmacarthur)

    Also, if that feedback helped you out, would you mind leaving COG a review? I’d really appreciate it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter if OG exists’ is closed to new replies.