• I’d like to give a page an ID so that I can style it differently, how do I do that please?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • By default every page in WP has an class in the body which is .page-id-XX, if you don’t have that then you need to check if your theme has the following in the header.php.

    
    <body <?php body_class(); ?>>
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    for example, examine the <body> tags on your site. This is one from mine:

    <body class="page-template-default page page-id-4 wp-custom-logo wp-embed-responsive has-header-image page-one-column colors-light">

    page-id-4 is the unique class for this page.

    All well-constructed themes use the body_class() function, as noted above. So, it depends on your theme.

    if using the default added page id does not work for you, you could add your own ID to the body_class by using a filter function, and you could set this ID by using a custom field;
    https://developer.www.ads-software.com/reference/functions/body_class/

    Custom Fields

    Thread Starter MyWorldz

    (@myworldz)

    I see the unique class for the page. I’ll try that and see if it does what I want, if not I will add an ID.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add ID to Page’ is closed to new replies.