Skip to content

Instantly share code, notes, and snippets.

View sybrew's full-sized avatar

Sybre Waaijer sybrew

View GitHub Profile
@sybrew
sybrew / tsf-disable-page-12.php
Created June 29, 2025 05:11
Disable TSF on page ID 12
<?php
// Do not include the opening PHP tag if PHP is already opened.
\add_filter(
'the_seo_framework_query_supports_seo',
/**
* Disables SEO support for page ID 12.
*
@sybrew
sybrew / tsf-allow-empty-category-indexing.php
Created June 18, 2025 13:19
This code snippet modifies The SEO Framework plugin to let search engines index empty category archives by disabling the noindex directive. Note: WordPress may still emit a 404 response.
<?php
// Do not open PHP if PHP is already opened.
add_filter(
'the_seo_framework_enable_noindex_no_posts',
function ( $noindex ) {
if ( is_category() ) {
// To allow indexing, so set noindex to false.
@sybrew
sybrew / tsf-acf-html-excerpt-description.php
Last active May 21, 2025 19:34
Use ACF fields for meta descriptions via excerpt extraction in The SEO Framework plugin, supporting both admin and front-end contexts.
<?php
// Do not include the PHP opening tag if PHP is already open.
// Per email Wojciech.
add_filter( 'the_seo_framework_description_excerpt', 'my_tsf_acf_custom_excerpt', 10, 3 );
/**
* Use ACF HTML fields as meta description for specific CPTs.
*
* @param string $excerpt The auto‐generated excerpt.
@sybrew
sybrew / semversorter.js
Last active June 23, 2025 01:12
Semver sorter
/**
* Sorts an array of version objects based on their semantic version numbers,
* including pre-release versions.
*
* This function parses each version string using a regular expression to
* extract its numeric, pre-release, and build components and then compares
* them to order the array.
*
* It supports complex versions such as (in order) "1.4.9", "1.5.0-alpha",
* "1.5.0-alpha2", and "1.5.0", ensuring that pre-release versions are sorted
@sybrew
sybrew / tsf-article-type-filter.php
Created March 11, 2025 00:52
This filter for The SEO Framework (Articles extension) sets the Article Type to "NewsArticle" for 'post', 'web-story', and 'gira' post types.
<?php
// Do not include the PHP opening tag if PHP is already open
// Per email exchange with Renan.
add_filter(
'the_seo_framework_articles_data',
function ( $data ) {
if ( in_array( get_post_type(), [ 'post', 'web-story', 'gira' ], true ) ) {
@sybrew
sybrew / tsf-custom-taxonomy-term-title-and-description-generator.php
Last active July 2, 2025 13:10
Generates a custom title and description for taxonomy terms.
<?php
// Do not include the PHP opening tag if PHP is already open
// Per https://wordpress.org/support/topic/term_title-in-custom-taxonomies-archive-titles/
add_filter(
'the_seo_framework_generated_archive_title_items',
/**
* Filters the generated archive title items.
*
@sybrew
sybrew / tsf-unset-schema-listings-cpt.php
Created January 20, 2025 18:21
Unset Schema for TSF on listings Custom Post Type
<?php
// Do not include the PHP opening tag if PHP is already opened.
add_filter(
'the_seo_framework_meta_generator_pools',
function ( $generator_pools ) {
if ( 'listings' === tsf()->query()->get_post_type_real_id() )
return array_diff( $generator_pools, [ 'Schema' ] );
@sybrew
sybrew / tsf-acf-filter-excerpt.php
Created December 3, 2024 20:22
Filters The SEO Framework's excerpt and replaces it with "excerpt_description" created via Advanced Custom Fields.
<?php
// Don't include the PHP opening tag if PHP is already open.
add_filter( 'the_seo_framework_get_excerpt', 'my_tsf_acf_excerpt', 10, 2 );
/**
* @param string $excerpt The obtained excerpt.
* @param array|null $args The query arguments. Contains 'id', 'tax', 'pta', and 'uid'.
* Is null when the query is auto-determined.
* @return string The overwritten description.
@sybrew
sybrew / tsf-hot-woocommerce-product-title.php
Last active November 22, 2024 06:29
Adjust WooCommerce title for The SEO Framework with "Hot " at the start.
<?php
// Do not include the PHP opening tag if PHP is already opened.
add_filter(
'the_seo_framework_title_from_generation',
function ( $title, $args ) {
$is_product = false;
@sybrew
sybrew / process-tsf-term-html.php
Last active August 8, 2024 16:13
Process HTML for generated term descriptions in The SEO Framework.
<?php
add_filter(
'the_seo_framework_description_excerpt',
function ( $excerpt, $args ) {
if ( ! strlen( $excerpt ) ) return '';
if ( isset( $args ) ) {
$is_term = 'term' === The_SEO_Framework\get_query_type_from_args( $args );