How do I add a class to WordPress body class?

How do I add a class to WordPress body class?

To add your own class to this, you can pass an argument in to the function, like so: php body_class( ‘my-class’ );?>> This would add a body class of my-class on each page of your WordPress site.

How do I add a class to the body in a specific page?

How to add custom body class(es) to Pages in WordPress

  1. Install and activate Advanced Custom Fields (free or Pro). Add a new field group titled say, “Page Fields” having a body_class text-type field.
  2. Install and activate Code Snippets plugin.
  3. Edit the Page for which you wish to add a custom body class.

How do I change my WordPress body code?

How to Edit Your WordPress Source Code via FTP 📥

  1. Step 1: Locate or Create Your FTP Credentials.
  2. Step 2: Download an FTP Client such as FileZilla.
  3. Step 3: Log Into Your Web Hosting Environment Through FileZilla.
  4. Step 4: Edit Your Files.

How do I find my body tag?

Click the “header. php” file in the list of files at the right to open it in the Editor. The header. php file contains the body tag.

Can I add class to body tag?

$(“body”). attr(“class”, “about”); It uses jQuery’s attr() to add the class ‘about’ to the body. This works fine for adding a class to the body.

Where is body tag in WordPress?

Log into your WP admin panel, on the left sidebar, click on the “appearance” menu label, then select “theme editor”. Select the theme you want to edit from the dropdown on the top right, then scroll through the files until you locate the header. php file. The body open tag is in there.

What are WordPress body tags?

The body tag in WordPress is used to control how your content is displayed. Within that same section though, numerous metadata (unseen scripts) can be loaded without negatively impacting usability.

How do I learn to code on WordPress?

8 Resources for Learning to Code for WordPress

  1. View the PHP tutorials at W3Schools.
  2. View the WordPress Development for Beginners series.
  3. View the Learn WordPress Development videos.
  4. View the WordPress development courses at Udemy.
  5. View the courses at WPSessions.
  6. View the Professional WordPress book at

Which attribute is valid for body tag?


Attribute Description
background Image to be used a background
bgcolor Background color
link Color of text for unvisited hyperlinks
onafterprint Function to call user has printed document