Support » Plugin: Yoast SEO » [Plugin: WordPress SEO by Yoast] Fatal error: Using $this when not in object context

  • Resolved Adam Capriola

    (@adamcapriola)


    Got this error when I upgraded and try to view any non-cached page on my site:

    Fatal error: Using $this when not in object context in /var/www/html/pk/pkmncards.com/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 91

    I’m going to downgrade back to the earlier version of the plugin until this is resolved. Not sure if it’s something I did wrong, but in my functions.php I have been using stuff like this:

    $og_title = WPSEO_Frontend::title( false );
    $og_url = WPSEO_Frontend::canonical( false );
    $og_description = WPSEO_Frontend::metadesc( false );

    I’ve been using those to make some custom og tags.

    http://wordpress.org/extend/plugins/wordpress-seo/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Joost de Valk

    (@joostdevalk)

    You shouldn’t need to make custom og tags 🙂 my plugin does them all, but yeah those function calls are causing the error.

    Thread Starter Adam Capriola

    (@adamcapriola)

    Thanks for the reply Joost! I wanted to fine tune some things (namely retrieving the thumbnail image with help from Get The Image), so I decided it would be best to generate them myself. How would I go about retrieving those values now?

    Plugin Contributor Joost de Valk

    (@joostdevalk)

    Don’t know 🙂 I’ll leave that as an exercise to you 🙂

    Thread Starter Adam Capriola

    (@adamcapriola)

    Figured it out! 🙂

    Instead of:

    $og_title = WPSEO_Frontend::title( false );
    $og_url = WPSEO_Frontend::canonical( false );
    $og_description = WPSEO_Frontend::metadesc( false );

    Use:

    $object = new WPSEO_Frontend();
    $og_title = $object->title( false );
    $og_url = $object->canonical( false );
    $og_description = $object->metadesc( false );

    Thanks for the solution Adam.

    I use the WPSEO title() and metadesc() methods in some validation code I added to my theme. Instansiating the WPSEO_Frontend class as you suggested fixed the problem.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Fatal error: Using $this when not in object context’ is closed to new replies.