WordPress.org

Forums

WordPress SEO by Yoast
[resolved] Fatal error: Using $this when not in object context (6 posts)

  1. Adam Capriola
    Member
    Posted 3 years ago #

    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/

  2. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

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

  3. Adam Capriola
    Member
    Posted 3 years ago #

    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?

  4. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    Don't know :) I'll leave that as an exercise to you :)

  5. Adam Capriola
    Member
    Posted 3 years ago #

    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 );
  6. Andrew Biss
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress SEO by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic