Skip to content

Instantly share code, notes, and snippets.

@amboutwe
Last active May 3, 2021 19:35
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save amboutwe/c186b93dc4a6bc74256308070537bd1e to your computer and use it in GitHub Desktop.
Save amboutwe/c186b93dc4a6bc74256308070537bd1e to your computer and use it in GitHub Desktop.
Disable Yoast SEO Primary Category Feature
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Disable Yoast SEO Primary Category Feature
* Credit: Yoast development team
* Last Tested: Jan 24 2017 using Yoast SEO 4.1 on WordPress 4.7.1
*/
add_filter( 'wpseo_primary_term_taxonomies', '__return_empty_array' );
@elvismdev
Copy link

I think this is the right way to fully disable this now:

add_filter( 'wpseo_primary_term_taxonomies', '__return_empty_array' );

When using __return_false it drops me a PHP notice in the backend:

Notice: Trying to get property of non-object in /vagrant/public/wp-content/plugins/wordpress-seo/admin/class-primary-term-admin.php on line 189

@amboutwe
Copy link
Author

@elvismdev Thanks for the feedback.

@Blogthetech
Copy link

Where should I enter the above code?

@kasamatsu64
Copy link

functions.php

@tngraessler
Copy link

Thanks! Works perfectly! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment