Adam Capriola
Member
Posted 1 year 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/
You shouldn't need to make custom og tags :) my plugin does them all, but yeah those function calls are causing the error.
Adam Capriola
Member
Posted 1 year 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?
Don't know :) I'll leave that as an exercise to you :)
Adam Capriola
Member
Posted 1 year 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 );
Andrew Biss
Member
Posted 1 year 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.