How to add a class to the element?

I’m using the X-Theme in WordPress and I ran into an issue where I needed a CSS class in the tag, but only on one page. This is the code I added:

<!– If page#=103, add this class –>
<?php
if( is_page( 103 ) ) {
?>
<html class=”html-homepage”>
<?php
}
?>

The code went into the _header.php file and appears to be working with no issues.

My question is wondering if this method will break anything or if this is a super hacky way of doing this? I was unable to find a different solution that worked for me.

It looks like since WordPress is doing the processing, it should be fine, but I wanted to make sure that this won’t interfere with other WordPress functionality.

Thanks!

Read more here:: <a href=https://wordpress.stackexchange.com/questions/316372/how-to-add-a-class-to-the-html-element target="_blank" title="How to add a class to the element?” rel=nofollow>How to add a class to the element?

Leave a Reply

Your email address will not be published. Required fields are marked *