Skip to content

Instantly share code, notes, and snippets.

View amboutwe's full-sized avatar

Angi amboutwe

View GitHub Profile
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Log reason for "could not be resolved" redirect error
* Credit: Yoast team
* Last Tested: Nov 20 2024 using Yoast SEO 23.9 on WordPress 6.7
*/
function my_log_http_api_debug_event( $response, $context, $class, $parsed_args, $url ){
error_log( "HTTP API Debug: URL: " . $url . " Response: " . print_r( $response, true ) );
<?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/
*/
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Disable Yoast SEO Emoji Script
* Credit: Yoast team
* Last Tested: Oct 24 2023 using Yoast SEO (free and premium) 21.4 on WordPress 6.3.2
*/
add_filter( 'wpseo_premium_load_emoji_picker', '__return_false' );
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change the pagination limit for the Yoast SEO bulk editor
* Credit: https://github.com/emmelemme
* Last Tested: Aug 08 2023 using Yoast SEO 20.12 on WordPress 6.2.2
* Default = 10 items per page
*/
add_filter('wpseo_posts_per_page', function($number){
@amboutwe
amboutwe / yoast_seo_title_add_separators.php
Last active September 24, 2022 08:40
Add custom separators to the Yoast SEO options
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Add custom separators to the Yoast SEO options
* Credit: Yoast team
* Last Tested: September 2, 2021 using Yoast SEO 17.0 on WordPress 5.8
*/
add_filter( 'wpseo_separator_options', 'yoast_seo_title_add_separators', 10 , 1 );
@amboutwe
amboutwe / yoast_seo_breadcrumb_remove_static_blog_page_only.php
Created May 12, 2021 22:46
Remove Yoast breadcrumb from static blog page
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast breadcrumb from static blog page
* Credit: Yoast team
* Last Tested: May 12, 2021 using Yoast SEO 16.2 on WordPress 5.7.1
*/
add_filter( 'wpseo_schema_webpage', 'remove_breadcrumb_schema_ref', 10, 1);
function remove_breadcrumb_schema_ref( $piece ){
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Prevent Yoast SEO for adding specific post types to indexables
* Credit: Yoast team
* Last Tested: Jan 18 2021 using Yoast SEO 15.6.2 on WordPress 5.6
* Documented: https://github.com/Yoast/wordpress-seo/blob/trunk/src/helpers/post-type-helper.php#L90
* Common post types: 'post', 'page', 'attachment', 'product'
*/
<?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;
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove the datePublished from the Yoast SEO meta tags
* Credit: Yoast team
* Last Tested: Jul 27 2023 using Yoast SEO 20.12 on WordPress 6.2.2
*/
function remove_date_metatags ( $presenters ) {
return array_map( function( $presenter ) {
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Include empty terms in the sitemap
* Credit: Yoast team
* Last Tested: Mar 22 2019 using Yoast SEO 10.0.1 on WordPress 5.1.1
*/
add_filter('wpseo_sitemap_exclude_empty_terms', '__return_false');