• Resolved Beats247

    (@beats247)


    Hi there,
    I was writing to you before but you closed the thread. I found out thwat the problem is. Activating Facebook Open Graph meta data and Twitter card meta data crashes vendor pages on my site (it’s loading to death, internal server error 500). Is it possible to deactivate these two options on a single page only instead of globally? If so, what function do I need to add? For now I had to deactivate it completely or the site isn’t working. That’s not really a good solution though. Everything is up-to-date (WordPress, Yoast)

    Thanks in advance.

    Kind regards

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    In order to disable open graph meta on a specific page, you’ll need to implement the wpseo_opengraph filter by conditionally checking the page using is_page() function on your site.

    Thread Starter Beats247

    (@beats247)

    Ok, thanks for the reply. Not sure how to do that though ??
    What’s the code I need to add to my child theme (functions.php) so this will work?
    The page I want to exclude from open graph meta is the https://2018.beats24-7.com/vendor/ template page.

    Thanks again

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We can’t offer support on the custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting an 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.

    Thread Starter Beats247

    (@beats247)

    The theme developers tell me it would be paid custom work because it is not an issue caused by their theme. You are telling me you don’t want to break my website…. It’s just a little bit of code for the child theme, if it is not working I can remove it. Please, any help wuld be appreciated! Thanks

    Thread Starter Beats247

    (@beats247)

    I found this on your GitHub:
    https://gist.github.com/amboutwe/811e92b11e5277977047d44ea81ee9d4

    Do I need to use the ” yoast_seo_opengraph_remove_single.php ” Snippet? Would that be correct?

    add_action(‘wp_head’, ‘remove_one_wpseo_og’, 1);
    function remove_one_wpseo_og() {
    if ( is_single ( beats24-7.com/vendor/ ) ) {
    remove_action( ‘wpseo_head’, array( $GLOBALS[‘wpseo_og’], ‘opengraph’ ), 30 );
    }

    Plugin Support amboutwe

    (@amboutwe)

    Yes, the code work as of the last tested date on that code snippet. However, the is_single() does not accept a URL or portion of a URL. Instead, it would be a an ID for the post or 'post title' with the title of the post.

    If the target URL is not a post, you may need to switch to another method for checking the URL, like is_page() or is_singular().

    Thread Starter Beats247

    (@beats247)

    Thanks for your reply! I added the code to the functions.php of the child theme but it didn’t work. The website didn’t load anymore. Do you see any mistake?

    add_action(‘wp_head’, ‘remove_one_wpseo_og’, 1);
    function remove_one_wpseo_og() {
    if ( is_singular ( beats24-7.com/vendor/ ) ) {
    remove_action( ‘wpseo_head’, array( $GLOBALS[‘wpseo_og’], ‘opengraph’ ), 30 );
    }

    using is_page didn’t work either. Is it a problem because of the url I entered? The pages that are not working with the open graph meta enabled are vendor pages like e.g.: https://2018.beats24-7.com/vendor/testvendor/. That’s why I deactivated the meta data globally for now.

    Thanks again

    • This reply was modified 7 years ago by Beats247.
    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    This is to be expected as you’ve used the parameter in the is_singular() function in a wrong way. You’ve used a string without the quotation mark in it. Please, refer to these following WordPress Codex pages to learn more about how they work:

    Thread Starter Beats247

    (@beats247)

    Thanks for the help, it still isn’t working though. Even just adding a standard post string doesn’t work.

    add_action(‘wp_head’, ‘remove_one_wpseo_og’, 1);
    function remove_one_wpseo_og() {
    if ( is_singular ( ‘post’ ) ) {
    remove_action( ‘wpseo_head’, array( $GLOBALS[‘wpseo_og’], ‘opengraph’ ), 30 );
    }

    The whole website is not loading.

    EDIT: Ok, the closing } was missing. Open Graph meta still doesn’t get deactivated on vendor pages though. I don’t know how to address them… I tried

    if ( is_singular ( ‘vendor’ ) )
    if ( is_page ( ‘vendor’ ) )
    if (is_page_template( ‘page-vendor.php’ ) )
    if ( is_page( ‘vendor’ ) || ‘9016’ == $post->post_parent )

    They all have the beats24-7.com/vendor/vendorxyz… url but I don’t know how to add this and if these can be called sub pages. Any help would be appreciated, thank you!

    Have a great weekend.

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    The following should do the trick if you’d like to disable Yoast SEO generated social open graph meta on single post page:

    add_action('wp_head', 'remove_all_wpseo_og', 1);
    function remove_all_wpseo_og() {
    	if ( is_single() ) {
    		remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    	}
    }
    
    Thread Starter Beats247

    (@beats247)

    Thanks Mazedul, but I am not looking to deactivate it on single post pages. Anyway, I now have the correct code to address the pages I want to disable open graph meta on, but your code provided on github doesn’t seem to work. The page https://2018.beats24-7.com/vendor/testvendor is not loading, caused by the fact that open graph meta is still not disabled on this page:

    That’s the code:

    if( is_page_template( 'page-fesdashboard.php' ) || is_page_template( 'page-vendor.php' ) )  {
    
    // your code to remove yoast og
    add_action('wp_head', 'remove_all_wpseo_og', 1);
    function remove_all_wpseo_og()  { 
        remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
       }
    }

    Thanks again!

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    Unfortunately, we are unable to confirm why the custom isn’t working on your site as this depends on your website and may need a tweak. 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.

    Thread Starter Beats247

    (@beats247)

    The developers of my theme just told me that this is a wrong piece of code. They are not helping me either though, so… all that doesn’t make any sense to me.
    Anyways, thank you I guess.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Yoast enabled meta data crashes site (FB/Twitter)’ is closed to new replies.