Skip to content

Instantly share code, notes, and snippets.

View amboutwe's full-sized avatar

Angi amboutwe

View GitHub Profile
@amboutwe
amboutwe / yoast_seo_admin_user_remove_social.php
Last active November 1, 2023 22:59
Remove Yoast SEO Social Profiles From All Users
/* Remove Yoast SEO Social Profiles From All Users
* Credit: Yoast Developers
* Last Tested: Nov 01 2023 using Yoast SEO 21.5 on WordPress 6.3.2
*********
* Use this code to hide the fields shown under Admin > Users > Edit user
* Previously entered profiles will be included in schema
* To limit or remove user schema, use 'wpseo_schema_person_social_profiles' filter
* Link: https://developer.yoast.com/features/schema/pieces/person/#social-profiles
*/
@amboutwe
amboutwe / yoast_seo_dashboard_widget_remove.php
Last active November 16, 2023 00:43
Remove Yoast SEO Dashboard Widget
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Dashboard Widget
* Credit: Unknown
* Last Tested: Sep 15 2022 using Yoast SEO 19.6.1 on WordPress 6.0.2
*/
add_action('wp_dashboard_setup', 'remove_wpseo_dashboard_overview' );
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Sync post meta to Yoast Indexable
* Credit: Yoast team
* Last Tested: Dec 20 2022 using Yoast SEO 19.13 on WordPress 6.1.1
*/
// The ID of the post to modify
$post_id = 1;
@amboutwe
amboutwe / yoast_seo_roles_remove.php
Last active December 13, 2023 10:11
Yoast SEO user roles
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO user roles
* Credit: Yoast Team
* Last Tested: Oct 25 2017 using Yoast SEO 5.7.1 on WordPress 4.8.2
*/
// Remove Yoast `SEO Manager` role
if ( get_role('wpseo_manager') ) {
remove_role( 'wpseo_manager' );
@amboutwe
amboutwe / yoast_video_remove_yandex.php
Last active January 3, 2024 07:22
Remove Yandex tags from Yoast SEO Video
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yandex tags from Yoast SEO Video
* Credit: Yoast development team
* Last Tested: May 12 2017 using Yoast SEO Video 4.7 on WordPress 4.7.4
*/
add_filter( 'wpseo_video_yandex_support', '__return_false' );
@amboutwe
amboutwe / yoast_seo_opengraph_change_image_size.php
Last active January 11, 2024 20:48
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Include authors of CPTs in the Yoast author sitemap
* Credit: Yoast team
* Last Tested: Jan 29 2024 using Yoast SEO 21.9.1 on WordPress 6.4.2
* For optimial SEO, please ensure that CPT posts are included in the core author archive output
* Example: https://wpdevdesign.com/how-to-add-cpt-entries-in-author-archives/
*/
@amboutwe
amboutwe / yoast_seo_admin_remove_columns.php
Last active February 1, 2024 16:37
Remove Yoast SEO columns from posts and pages
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Columns
* Credit: Andrew Norcross http://andrewnorcross.com/
* Last Tested: Jun 09 2020 using Yoast SEO 14.3 on WordPress 5.4.1
*
* If you have custom post types, you can add additional lines in this format
* add_filter( 'manage_edit-{$post_type}_columns', 'yoast_seo_admin_remove_columns', 10, 1 );
* replacing {$post_type} with the name of the custom post type.
@amboutwe
amboutwe / yoast_seo_breadcrumb_add_woo_shop.php
Last active March 15, 2024 14:55
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@amboutwe
amboutwe / wordpress_robots_custom.php
Last active March 20, 2024 15:22
Filters and example code for Yoast SEO robots or WP robots.txt
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Replace Disallow with Allow Generated Robots.txt
* Credit: Unknown
* Last Tested: June 09 2020 using WordPress 5.4.1
*/
add_filter('robots_txt','custom_robots');