Yoast SEO Plugin Variables and Custom Functions

Yoast SEO Tutorials

With Yoast keep making changes like they are changing their underwear each day, I’ve decided to share RankYa settings for Yoast SEO Plugin setup. Here’s are the variables to use when setting up Yoast WordPress SEO Plugin

Content Types


SEO title: %%title%% %%page%%

Meta description: %%excerpt%%


SEO title: %%title%%

Meta description: %%excerpt%%


Redirect attachment URLs to the attachment itself? This should be set to YES for most setups (as of Yoast SEO Plugin Version 12.5) if not use settings below

SEO title: %%title%%

Meta description: %%caption%%



SEO title: %%term_title%% Archives %%page%%

Meta description: %%category_description%%


SEO title: %%term_title%% Archives %%page%%

Meta description: %%term_description%%


SEO title: %%term_title%% Archives %%page%%

Meta description: LEAVE EMPTY

Category URLs

Remove the categories prefix > Keep


Author archives settings

SEO title: %%name%%, Author at %%sitename%% %%page%%

Meta description: Read more blog posts written on %%sitename%% by author: %%name%%

Date archives settings

SEO title: %%date%% %%page%%

Meta description: Read more blog posts written on %%sitename%% published on %%date%%


Content to put Before each blog entry = %%sitename%% Blog entry

Content to put After a blog entry = The post %%POSTLINK%% appeared first on %%BLOGLINK%%.

Yoast SEO Plugin WooCommerce Extension

Since WordPress is open source, and since most of the Plugins reside in github, if you are thinking of Yoast WooCommerce extension to use, just download from github

%%ct_product_cat%% Product category (comma separated)%%ct_product_tag%% Product tag (comma separated)%%ct_pa_<product-attribute-slug>%% Product attribute (comma separated). Be sure to remove the <> as they are not needed.

Which to use for Product? %%title%% can be purchased securely online at %%sitename%% store

Custom Functions for Yoast Plugin

/* **************************************************** BEGIN YOAST BLOCK ***************************************************************************** */ /* Using Yoast SEO Plugin? Then use these functions to remove annoying popups, divs and stupid SEO score */ function rankya_yoast_edits() { include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) { function yoast_remove_blocks_with_css() { if ( is_user_logged_in() && current_user_can( 'manage_options' ) || is_admin()) { ?> <style type="text/css"> [class*="is-dismissible"], #wpseo-dismiss-about, #wpseo-dismiss-recalculate, li#wp-admin-bar-wpseo-menu, #sidebar-container #sidebar, .wpseotab.active > p:nth-child(6), .wpseotab.active > p:nth-child(7), #wpseo-dismiss-gsc, #yst_opengraph_image_warning, #metamessage.error, #blocking_files, [id*="metadesc_found"][class*="wrong"], .wpseo-tab-video-container, #wpseo-dashboard-overview, #i18n_promo_box, #wpseo-score-readability.column-wpseo-score-readability, .yoast-issue-counter,#yoast_internal_linking, div.yoast_premium_upsell_admin_block, #wpseo-debug-info,[class*="container__alert"],[class*="container__warning"], #wpseofocuskeyword { display:none !important } .postbox { border:1px solid #e5e5e5 !important } </style> <?php } //end if user logged in } //end yoast styles removal add_action( 'admin_head', 'yoast_remove_blocks_with_css' ); // hook in to action admin_head to place this CSS function yoast_seo_dashboard_overview_widget() { remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' ); } add_action( 'wp_dashboard_setup', 'yoast_seo_dashboard_overview_widget' ); function yoast_ignore_tour() { update_user_meta( get_current_user_id(), 'yoast_ignore_tour', true ); } add_action( 'admin_init', 'yoast_ignore_tour', 999 ); function wpseo_disable_rel_next_home( $link ) { if (is_home() || is_front_page()) { return false; } } add_filter( 'wpseo_next_rel_link', 'wpseo_disable_rel_next_home' ); function remove_stupid_adminbar_menu_for_yoast() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wpseo-menu'); } add_action( 'wp_before_admin_bar_render', 'remove_stupid_adminbar_menu_for_yoast' ); /* function remove_json_ld_output( $data ) { $data = array(); return $data; } add_filter('wpseo_json_ld_output', 'remove_json_ld_output', 10, 1); add_filter( 'wpseo_json_ld_output', '__return_empty_array' ); add_filter( 'disable_wpseo_json_ld_search', '__return_true' ); */ function rankya_columns_filter( $columns ) { unset($columns['wpseo-score']); unset($columns['wpseo-focuskw']); return $columns; } add_filter( 'manage_edit-page_columns', 'rankya_columns_filter',10, 1 ); add_filter( 'manage_edit-post_columns', 'rankya_columns_filter',10, 1 ); //remove the comments add_action('get_header', 'start_ob'); add_action('wp_head', 'end_ob', 999); function start_ob() { ob_start('remove_yoast'); } function end_ob() { ob_end_flush(); } function remove_yoast($output) { if (defined('WPSEO_VERSION')) { $targets = array( '<!-- This site is optimized with the Yoast SEO plugin v'.WPSEO_VERSION.' - https://yoast.com/wordpress/plugins/seo/ -->', '<!-- This site is optimized with the Yoast SEO plugin v'.WPSEO_VERSION.' - https://yoa.st/1yg?utm_content='.WPSEO_VERSION.' -->', '<!-- This site is optimized with the Yoast SEO Premium plugin v'.WPSEO_VERSION.' - https://yoast.com/wordpress/plugins/seo/ -->', '<!-- This site is optimized with the Yoast SEO Premium plugin v'.WPSEO_VERSION.' - https://yoa.st/1yg?utm_content='.WPSEO_VERSION.' -->', '<!-- / Yoast SEO plugin. -->', '<!-- / Yoast SEO Premium plugin. -->', '<meta name="robots" content="noodp"/>' ); $output = str_ireplace($targets, '', $output); $output = trim($output); $output = preg_replace('/^[ \t]*[\r\n]+/m', '', $output); } return $output; } function rankya_remove_yoast_notice() { if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) { if ( !class_exists( 'Yoast_Notification_Center' ) ) { require_once( WP_PLUGIN_DIR . '/wordpress-seo/admin/class-yoast-notification-center.php' ); } remove_action( 'all_admin_notices', array( Yoast_Notification_Center::get(), 'display_notifications' ) ); } /* just stop using the stupid Yoast redirections altogether (if you need to control redirection, use https://redirection.me/ free plugin) //Yoast SEO Disable Automatic Redirects for Posts And Pages add_filter('wpseo_premium_post_redirect_slug_change', '__return_true' ); //Yoast SEO Disable Automatic Redirects for Taxonomies (Category, Tags, Etc) add_filter('wpseo_premium_term_redirect_slug_change', '__return_true' ); // Yoast SEO Disable Redirect Notifications for Posts or Pages: Moved to Trash add_filter('wpseo_enable_notification_post_trash', '__return_false'); //Yoast SEO Disable Redirect Notifications for Posts and Pages: Change URL add_filter('wpseo_enable_notification_post_slug_change', '__return_false'); // Yoast SEO Disable Redirect Notifications for Taxonomies: Moved to Trash add_filter('wpseo_enable_notification_term_delete','__return_false'); // Yoast SEO Disable Redirect Notifications for Taxonomies: Change URL add_filter('wpseo_enable_notification_term_slug_change','__return_false');*/ } //end rankya_remove_yoast_notice add_action( 'admin_init', 'rankya_remove_yoast_notice' ); } //end if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) or premium check) } //end function rankya_yoast_edits() // UPON ACTIVATION DO add_action( 'init', 'rankya_yoast_edits' ); /*end rankya_yoast_edits*/ /* **************************************************** END YOAST BLOCK ***************************************************************************** */

Tips for Setting up Yoast SEO Plugin

Keep in mind always that when you setup Yoast Plugin through its general settings, that means, if you somehow forget to optimize individual posts pages or products by creating unique SEO Title and Meta Description, then, the general settings (and snippet variables) will be used. But the important thing to remember is, you should not forget creating unique SEO Title and Meta Description for each URL you are creating.

Yoast SEO Title Option Best Practice

  • For blog posts targeting long tailed keywords (which are a must to do when you want to rank competitive keywords as well): Entire Target keywords should be placed in SEO Title.
  • For pages or blog posts targeting short tailed keywords (less than 3 or 4 words): Entire Target keywords + Call to Action (entice the Google searcher who will see your results amongst others to click YOUR website details)
  • For Products (WooCommerce): Product Name (If short (less than 3 or 4 words)): Entire Target keywords + Call to Action. If product name is longer than 4+ words: Entire Target keywords

Do you know of better settings? Comment below or share this post with other WordPress site owners using Yoast SEO Plugin.

Is your business website ready for latest 2022 Google's Page Experience algorithm update? Getting website traffic but no conversions? You can change all that with Master Class Course by RankYa (Free Lessons Included)

Learn how press here

By RankYa

RankYa is a passionate digital marketer, website optimizer, content creator, and a fully qualified web developer helping businesses of all sizes (big or small) to achieve better results online. We are a reputable and registered Australian business serving valued clients worldwide since 2008, built on hard work, honesty and providing exceptional personalized service

We love sharing our passion through freely available how to videos and courses related to business website marketing and optimization, Google (Search Console, Ads, Analytics, YouTube), SEO, HTML5, Structured Data and WordPress. Thank you for visiting our website. Rest assured that it will serve you well as well.


  1. “triple check author and date archives and make sure that they do NOT redirect to the home page”
    Why not redirect them if we have one author blog?

  2. Hi Savas! I was waiting for your post after this “Another Great” update from yoast. If you can sugest some alternative way : how to seo wordpress site without yoast, i’ll be glad to hear you!
    This is ridiculous, they are trying to make it worse…
    After the major update and every time i was updating to new versions, something happens, i’m losing my xml site maps, my site is crashing and some other issues…

    1. I also believe the Yoast team has lost the plot with these updates (almost everyday???) no other WordPress plugin updates as much as Yoast (thus, these consistent updates causes issues) in fact, there are major flaws with v7 (triple check author and date archives and make sure that they do NOT redirect to the home page)

Leave a comment

Your email address will not be published. Required fields are marked *