Forums

using post and page slug in body id (2 posts)

  1. malloreigh
    Member
    Posted 1 year ago #

    I'm interested in doing page-by-page custom CSS by setting a body id to the post/page slug. I've searched through the posts on this topic but I'm not sure if the codes that people have come up with will assign both post and page slug, and I don't write PHP myself.

    So, I need a function to pull page slug so that I can use it as an ID in header.php. Is there a way I can do this?

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    <body <?php if(is_singular()) { echo ' class="'.$post->post_name.'"'; } ?>>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags