The code below works, basically it adds your class to the wordpress body_class() array..
add_filter('body_class','my_class_names');
function my_class_names($classes) {
// add 'class-name' to the $classes array
$classes[] = 'mobile';
// return the $classes array
return $classes;
}
You can read more on this on the WP codex here
Related Posts:
- Add Useragent to the body class?
- Best way of adding CSS which can be manipulated by the user via theme option panels?
- Using PHP to toggle stylesheet and header image, set in cookie
- Shortcode content output but not in correct place
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to style options page in dashboard?
- Css loads very slow [closed]
- responsive.css in the WordPress should be prioritized
- height should be set to auto to avoid pixelation in the post thumbnail function
- How to make container class in PHP
- How to remove sidebar primary widget on Mobile on category page [closed]
- CSS change in woo commerce Place Order Text [closed]
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- how to changes mobile menu toggle breakpoint in WordPress
- PHP function for horizontal Woocommerce thumbnails and badges
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- I got big white screen when i attach main style sheet of Html in functions.php
- Site title not showing. Please help me
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Add class for the_post_thumbnail_caption()
- Displaying POST content with HTML tags and all
- Highlight Single Page Ancestor
- Styling admin page rows in order of importance (checkboxes)
- How to have Function of a plugin using global vars into a shortcode?
- Cant get theme to change footer color through theme customizer
- How to add margin underneath woocommerce total price amount -> productpages
- How do I get Roboto Google Font to display normal font-style? [closed]
- Integrating CSS Into a WP Function Call [closed]
- Load slideshow.css file only if Slideshow is checked / on
- Sorting Problem
- How to get the original price of the product in woocommerce?
- How to add 2 posts under another post? Formatting should be intact
- Get widget settings function?
- Archive dropdown styling not applied
- Different background-image by category
- enqueue multiple Google fonts with multiple weights and styles (italic)
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- What is the fastest way to load PHP functions that are only used in one theme template?
- Adding tawk.to code just before body tag on functions.php file
- add_action shortcut?
- ACF: how do I get the fields and its values of a specific group?
- Get page that displays all children of taxonomy parent
- Function to capture a value and store it in a variable
- WordPress Multiple Navigation bars
- Adding a widget function into the php theme file
- My new button is in the wrong place
- Checking array against author id in loop
- Call to undefined method – Download Monitor
- How do I link a button I created in theme customizer to a function?
- Which is the correct way to conditionally enqueue a CSS file?
- Read array in php?
- Tell WP register script to load a script only when the entire page is loaded
- Can’t save php string to a custom field
- What does $_GET[‘iphone’] do?
- get_template_directory adding FTP root folders in urls
- Fatal error: Call to undefined function register_new_user()
- wordpress admin plugin menu custom css
- Co-Authors Plus: How do I get all authors with a query?
- Why i can’t get custom fields value or post ID via Ajax?
- How to reference PHP in Javascript
- Fallback image URL if no featured image exists via a shortcode function
- Deactivate a plugin on wp version
- making php value numeric
- the_post_thumbnail issues
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- WP insert post Redirect after function has executed
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- How to Send Pingbacks for all Posts in WordPress?
- Add other class content with reference class value
- HTML comment cause issue in functions.php script root
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Cannot dequeue Elementor Font Awesome css
- How to find and delete a menu item in php?
- How to display post meta bellow every posts
- WordPress Ajax filter: Create two loops for different output styles?
- Handling form actions in WordPress
- How to call a function from functions.php with ajax?
- Set user status to absent on WordPress
- Shortcode’s output to use as other shortcode’s parameter
- Showing wordpress latest post thumbnails in slider with auto increment
- Custom Thumbnails [closed]
- My function echos only “array”
- Notify admin (by email) if post added with specific tag
- Retrieving specific images from Media Library
- Can’t put a hyperlink on Featured Post’s Image
- Limit Taxonomy Parents
- WordPress HTML Helper
- List sibling pages widget, exclude current page
- How to add button to top of theme customizer?
- Send foreach $_post method to contact form 7 [closed]
- Load files content [closed]
- Options.php loop won’t show!
- Predefine Magazine Style Layouts
- inner-wrap div pushing custom table far down on page
- Automatically change insurance quantity based on cart total [closed]
- Option value not getting updated until page refresh in WordPress
- How to pass value to add_filter wpcf7_form_tag from another function?
- hiddenQuestions.find is not a function