Skip to content

Instantly share code, notes, and snippets.

@rmarcano
rmarcano / Add to posts with the "premium" tag
Last active July 1, 2025 17:14
Add "IsAccessibleForFree" to the Article schema
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Conditionally sets 'isAccessibleForFree' in Yoast's Article schema based on the 'premium' post tag.
* - If a post has the 'premium' tag, isAccessibleForFree is set to 'false'.
* - For all other posts, isAccessibleForFree is set to 'true'.
*
* Credit: Yoast team
* Last Tested: Jun 24 2025 using Yoast SEO 25.3.1 on WordPress 6.8.1
@rmarcano
rmarcano / MyShortcodesFilter.js
Created November 19, 2024 17:36
Shortcode analysis.
const getShortcodes = (shortcodes) => {
shortcodes.push("analyze_field");
return shortcodes;
};
wp.hooks.addFilter( "yoast.analysis.shortcodes", "getShortcodes", getShortcodes );
@rmarcano
rmarcano / noindex_single
Created April 11, 2018 14:33
This snippet uses the wpseo_robots filter to add a "noindex, follow" to posts that match a certain condition (in this example, is_single()).
add_filter( 'wpseo_robots', function ( $robots ) {
if ( is_single() ) {
return 'noindex,follow';
}
return $robots;
});