Skip to content

Instantly share code, notes, and snippets.

@Pross
Created January 8, 2026 15:38
Show Gist options
  • Select an option

  • Save Pross/adbe2e6f1d24da89fae76d0ca034fab3 to your computer and use it in GitHub Desktop.

Select an option

Save Pross/adbe2e6f1d24da89fae76d0ca034fab3 to your computer and use it in GitHub Desktop.
People that want to use BB shortcodes on category archive descriptions ( I know I know! ) will find Yoast totally blows up your page.
<?php
/**
* Only Stack Exchange and actual DOCS were used to create this gist
*
* @see Certified AI Free Code
* @since Yesterday
*/
class FixYoastCat {
public $hooks = array( 'category_description', 'term_description' );
public $tags_to_remove = array( 'fl_builder_insert_layout', 'wpbb', 'wpbb-if', 'wpbb-else' );
public $term_description = '';
public $category_description = '';
function __construct() {
$this->run_before();
$this->run_after();
}
function run_before() {
foreach( $this->hooks as $hook ) {
add_action( $hook, function( $description ) use ( $hook ) {
$this->{$hook} = $description;
$pattern = get_shortcode_regex( $this->tags_to_remove );
$description = preg_replace_callback( "/$pattern/", 'strip_shortcode_tag', $description );
return $description;
}, 9 );
}
}
function run_after() {
foreach( $this->hooks as $hook ) {
add_action( $hook, function( $description ) use ( $hook ) {
$description = $this->{$hook};
return $description;
}, 11 );
}
}
}
new FixYoastCat;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment