It doesn’t appear that you can (easily) add arbitrary attributes to the <body>
tag.
However, WordPress provides the function body_class()
so you can add classes to the <body>
tag.
If your theme uses it, you’ll find something along these lines in a template file (eg. header.php
):
<body <?php body_class(); ?>>
In that case, you’ll be able to filter the array of classes being passed using the body_class
filter:
add_filter( 'body_class', 'wpse388651_body_class' );
function wpse388651_body_class( $classes ) {
$classes[] = 'my-custom-class';
return $classes;
}
Related Posts:
- dealing with large HTML output via plugin code
- How can I make my custom shortcode work in a Custom HTML Widget?
- Output in XHTML or HTML 5 for plugins?
- Editor not displaying dynamically after clicking on the button
- How to make a custom field as an editor in wordpress?
- How to trigger $_GET request within admin plugin page?
- How can I get WordPress to save comments in markdown format?
- How can i get the post’s full html source by its ID?
- Images under 1MB are not being compressed
- How to save Setting pages data to the database?
- How to translate to spanish wordpress hardcoded content/files?
- Can’t access 3rd party API, code works on local server but not on wordpress
- Form tries to download a file on submit
- hide load more button if there are no posts left to display
- How to create a “Most Popular” & “Latest” TAB in WordPress
- is_plugin_active function doesn’t exist
- How can I find plugins’ slug?
- How to call a plugin function from index.php
- My custom made plugin has “a new version available” which links to unrelated plugin
- Where can I find a schema of wordpress plugin core architecture?
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- WordPress Plugin Development from Scratch. How? [closed]
- How to fetch serialized data from wordpress options
- Passing URL parameters to WordPress pages and pretty url
- WordPress network: set themes and plugins for new blog
- How to get the custom page get_permalink?
- Plugin translations problem
- How can I add a custom meta value on file upload?
- Advanced Custom Fields into functions.php
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- Admin-ajax.php is dying “0” without processing function
- How do I register a stylesheet inside a WordPress widget?
- WordPress register_activation_hook table creation not working
- How to remove an Ajax action
- nonces in custom oop plugin
- I would like to use create a function in my custom plugin to tell WP to use a different header
- WordPress plugin for mail subscriptions [closed]
- Escape when echoed
- How to remove the woocommerce_checkout_process action hook in woocommerce if particular project in cart [closed]
- WP_Query ordering numbers as letters
- WordPress Automatic Plugin Update Renames Plugin Directory
- ‘wp_login’ action hook not working with wp-login.php file
- Execute a plugin only on post pages
- HTML in WooCommerce settings
- Can WordPress Plugin Directory Cache Delay the Upload of Images?
- Redirecting to home page after login as custom role WordPress
- Where (or when) should I register a new taxonomy?
- Create dynamic page content from custom WordPress plugin page
- How to change custom post type pemalink Hierarcy
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- Fixing WordPress’s Bug (failed to send buffer of zlib output compression) results in “White Screen of Death”
- Disable woocommerce cookies and delete cart data automatically
- How can I make my metabox appear?
- Consolidate plugin functionality into a theme
- qTranslate remove default directory from link
- Count posts by type including drafts and pending posts
- Redirect to another page using contact form 7? [closed]
- List the authors that have written posts in a category
- Separate database for a wordpress plugin
- WordPress Multisite: Programmatically Activate / Deactivate a Plugin of a Specific Blog
- remove all submenus from plugin
- Hook for page Request?
- composer not working on my plugin when i upload it to my website
- What is the WordPress approach to custom data?
- WordPress Fatal Errors [closed]
- Possible?? Pull Plugin Property Data to a Theme’s Custom Post Type
- How to render a template file using shortcode inside a plugin
- How to rewrite URL and get the values?
- Delete data from custom table when deleting a post
- Disable plugin visibility at the plugin directory
- Plugin is creating posts twice
- How to deactivate my plugin upon deactivation of NextGen
- Code for unique user visit count on every page WordPress
- Widgets are not displaying in the admin panel
- How to overwrite the category template in a plugin
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- show wc_add notices on particular page in woo commerce custom plugin development
- How to change the width of certain paragraph or header blocks?
- How to write different events from different functions in my file to a log file in WordPress
- Create a form and have custom menu display based on user answers?
- How to make a plugin api route have permission?
- Why my multisite is this slow? (stats inside)
- Modify Plugin PHP Class in Child Theme – Correct Method
- Problem with conditional woocommerce custom checkout field
- mailjet plugin – extend functionnalities and reuse api
- trying to create simple plugin to filter categories from all authors
- Change wp_mail SMTP settings for each E-Mail
- Proper Failure of Plugin Activation
- WordPress Thumbnail add action if no thumbnail
- How can I add the custom taxonomy categories to the posts and pages?
- Creating fields in the database
- Pass strings to plugin function [closed]
- How to create a page template using custom plugin
- WordPress 3,5 and Jquery version
- contact form 7 captcha support anyother captcha plugin? [closed]
- wordpress illegal string offset ‘parameter’ error
- How can I make my plugin detect if a certain theme is active?
- Plugin Block at the backend of every page or post
- Pulsing circle before the post title (Breaking news flash)