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
- Where should I save an API key of my user when installing my plugin?
- How to make a customize role and view a specific plugins base on that role?
- Reusable functions and tools (Framework)
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
- React JSX in WordPress Plugin Development
- My plugin wants to update another plugin
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Where (or when) should I register a new taxonomy?
- Woocommerce plugin for minimum order and add-to-card-step
- Self deactivate plugins after an action occurs
- How to get current post user id
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Issue with adding count to “subsubsub” aka quick links on custom_post_type
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Inserting HTML tag with ACF into shortcode
- How to slice an array using posts_per_page? [closed]
- White page on custom plugin option submit
- Can I use a plugin for a singular page on my website?
- Simple ajax call not working in wordpress plugin
- Plugin version is not showing up in wordpress.org plugin directory
- Do action only on certain front end pages?
- Change plugin main file name (that is currently in the repo)
- Create dynamic page content from custom WordPress plugin page
- Plugin Options Not Saving to Database in WP 4.5
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- How to create ‘import dummy data’ option in custom wordpress plugin
- Call to a member function have_posts() on a non-object on normal loop
- JS Support Ticket – Auto create WP account
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- Private Plugin Updates – Localhost
- How to change custom post type pemalink Hierarcy
- Any hook for pre-plugin-update -either bulk or single plugin update
- Get plugin option in another PHP file
- wp_create_nonce function doesn’t work inside a plugin?
- Test files for plugin development
- Input with spaces in Shortcode attributes overwritten by defaults
- Unable to override pluggable function wp_mail
- Avoid class name collision when using third party libraries in plugins?
- How to create custom tables in WordPress using my own plugin?
- New User Form – Custom Menu Page
- Own plugin corrups plugin-activation
- wordpress plugin is not activating from widget
- All Users > User List > Update User Meta Field Inline
- Checking instances of scripts in wp_head
- How to save post change url youtube link?
- Best approach to fetch data from wp options to js file or php file
- Correct way to perform non-cacheable DB query
- Allow users of my plugin to define their own shortcode rather than use mine?
- Is it possible to create Custom Post plug-in?
- uninstall.php file in Plugin to clean DB
- Archive – same title for the first two posts
- Creating a plugin to sanitize comment and the url field before display only
- Edit Yoast SEO breadcrumbs output [closed]
- Creating plugin using simple_html_dom parser?
- Object Oriented Plugin not working
- Does WP identify plugin by plugin name or plugin_basename?
- switched from query_posts to WP_query, not working now?
- Making a plugin only available on the front-end for the logged in super admin
- Create entire wordpress as a github repositery?
- Help With MySQL to WPDB Query Conversion
- When to load auto-login code?
- AJAX search posts and pages
- How to find the origin of a file upload from within wp_handle_upload?
- How Do I Figure Out What File(s) to Edit from Looking at the Source Code [closed]
- How would I go about creating a user ranked post popularity page?
- CSV file generation failing
- Updating the Drag-To-Share eXtended share URLs?
- finding whether request is for post, and post id
- Building plugin with changeable custom post type values…advice needed
- How to get all of the activate_plugin action parameters?
- __callStatic method handler passed to add_action causes bug in PHP
- Enqueue WordPress plugin scripts below all other JS
- Display update notification messages like ‘What’s New’
- How to add Internationalization in WordPress using Javascript/React?
- CRUD and Frontend show from a custom table without shortcode
- How to get specific setting by settings_fields()?
- Save / Show multi line text in metabox
- Creating mySQL procedure with $wpdb