Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/fd8b6d1ad673adcd68187d09ad30f6bf to your computer and use it in GitHub Desktop.
Save Garconis/fd8b6d1ad673adcd68187d09ad30f6bf to your computer and use it in GitHub Desktop.
WordPress | Add post ID to HTML element
<?php
function add_id_to_html_element( $output ) {
global $post;
$output .= ' id="custom-id-' . $post->ID . '"';
return $output;
}
add_filter( 'language_attributes', 'add_id_to_html_element' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment