Skip to content

Instantly share code, notes, and snippets.

@mjangda
Last active January 21, 2022 02:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mjangda/3578355 to your computer and use it in GitHub Desktop.
Save mjangda/3578355 to your computer and use it in GitHub Desktop.
Don't let kses strip out ids from section tags
<?php
function x_allow_ids_on_tags() {
global $allowedposttags;
$tags = array( 'section', 'article' );
$new_attributes = array( 'id' => array() );
foreach ( $tags as $tag ) {
if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) )
$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
}
}
// Do it, to it!
add_action( 'init', 'x_allow_ids_on_tags' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment