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 do I make a shortcode to display Dokan seller badge list?
- How can we upload custom page files?
- Calling a PHP function from a menu item
- Removing website URL in comments causes misalignment of submit button and tickbox
- How Display Posts on category
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- allow subscribers to see private posts without plug in
- Replace word in “the_content” only for index.php
- How do you add customer capability after Woocommerce purchase?
- How to get specific image in media library with php
- Function set default image when image not present
- Custom location for attached images
- WooCommerce – Reset quantity input field when variation changes
- Query all posts of a custom taxonomy term
- get current product name in functions.php
- Get first URL from post content
- Setting custom canonical urls
- Handling Body class based on Template
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- Get_avatar filter?
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Can’t get page content in WordPress
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Way to querry data (tags) from a wordpress database?
- get post based on category chosen in drop down – The ajax method
- Slider loading issue
- Adding Default Settings to Theme My Login plugin
- Image as Sales Badge
- how to make separate field in wordpress user_data_
- Function not working at one place
- jQuery not defined
- Displaying the Month and Year that a page was Created?
- Changing custom logo link
- Add a class to the anchor tag on HTML5 gallery
- Conditional Header in wordpress
- Remove meta description on certain pages
- Menu — How to add “current-menu-grand-ancestor” css class
- Plugin CSS not enqueing
- Use menu link or onClick to set a variable
- Swapping wp_dropdown_categories function with wp_category_checklist
- functions.php is being included twice, creating PHP fatal errors
- Automatically remove a canceled order in Woocommerce
- Parent theme CSS overriding child CSS rules
- Display fields as values in array from external SQL DB
- Only Show Link If div Exists
- How to put a variable in a instance in the widget
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- how to remove metadata from the posts of my blog?
- Trying to establish connection to External Database
- add_action shortcut?
- Passing the custom field values in the wp_get_current_user array function
- Using fwrite() and “a” appends multiple times instead of once
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- How to insert a single row to WP database table?
- Get date numerical and separate?
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Theme Options Page – User Updates Logo
- WSoD being caused by this piece of code
- Converting HTML Template to WordPress Theme
- Set the background to a default image if there isn’t a specified “featured image”
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- How to use my style.css file outside of wordpress subdomain?
- Add a variable in functions.php and call it in single.php
- How to access global variable $menu inside a class function
- Dynamic Stylesheet loads but doesn’t finish
- Calling directories to load in wordpress
- WordPress add post format support not working
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?