Created
December 11, 2020 14:41
-
-
Save Garconis/fd8b6d1ad673adcd68187d09ad30f6bf to your computer and use it in GitHub Desktop.
WordPress | Add post ID to HTML element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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