There’s at least 3 options to choose from:
You can use the single CPT file name which you can grab from the source code in the body classes or a custom class which can be added directly to the single-cpt.php file or using a functions file with conditional tag.
.single-cpt {
your declarations
}
Or add directly to single-cpt.php file
add_filter( 'body_class', 'wpsites_cpt_body_class' );
function wpsites_cpt_body_class( $classes ) {
$classes[] = 'your-single-cpt-class';
return $classes;
}
Or with conditional in functions file
add_filter( 'body_class', 'wpsites_cpt_body_class' );
function wpsites_cpt_body_class( $classes ) {
if ( is_singular('your-cpt') ) {
$classes[] = 'your-single-cpt-class';
return $classes;
}
}
Related Posts:
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Delete Post With No Traffic?
- Automatically Creating Posts for Popular Forum Topics or Products [closed]
- WP get_permalink Return Wrong URL
- Is there a plugin to display certain posts on certain pages? [closed]
- plugin for wp_list_categories with posts
- Replace existing pages with new pages, keep menu links
- Use plugin or custom post type for game score functionality
- Output HTML only on individual post view
- View Private Published Page with URL Code (no login required)
- Add category selection to custom post type (plugin)
- Redirect to another page using contact form 7? [closed]
- How to backup single post in wordpress [closed]
- Moving FB comments at the end of page
- How can i summerize posts or news automatically in word press site?
- Delete data from custom table when deleting a post
- Link Posts to External URL
- Posts are deleted everyday at night
- Issues with Post 2 Post Plugin
- Get page type to display content
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- Looking for membership style plugin with edit option [closed]
- How to show custom post type in all post section?
- Support for simultaneous editing
- How to import my YouTube channel into WordPress?
- How to get 1 or 2 specific posts on top of my wordpress blog?
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Portfolio + Blog: multisite or plugin?
- Custom Field Template seriously messed up in WP 3.1.1
- My Category is too big on the Menu what can i do?
- how to load the language file in plugin?
- Plugin upgrade issue
- How to use get_theme_mod in gutenberg editor wordpress?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- How to embed HTML code from WP Coder plugin (or other) into Main Index Template of the theme
- Accessing post’s meta data based on user’s click of a post
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- How can I capture Memberpress user info after signup [closed]
- My plugin wants to update another plugin
- I have no idea “How change font for elements in widget?”
- With W3 Total Cache when I publish a post it does not appear in the homepage. Only if i purge all cache [closed]
- JS Support Ticket – Auto create WP account
- How to show Recent Page instead of Post?
- Remove Duplicator plugin from admin menu if not an administrator
- The problem with WordPress Importer
- Input with spaces in Shortcode attributes overwritten by defaults
- I want to extend the current themes’ single.php to display the meta fields of my CPT
- Cron job not firing
- Solutions to repost categories into multisite blogs?
- How to enable qTranslate languages tabs in custom plugin page
- How do I “get the next 10 posts after post_id == x”?
- Hiding posts – WP Hide Post not working
- Add a custom form on the post-new.php admin page
- Removing customise fields during plugin uninstallation
- Edit Yoast SEO breadcrumbs output [closed]
- What’s the best way to implement AJAX in WordPress?
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- Translating long texts with html formatting
- submit posts by unregistered users in wordpress
- Calendar Solution: Handling upcoming Dates with Posts?
- get_post_type on post.php
- Is there an easy way to flag posts in the admin area?
- How would I go about creating a user ranked post popularity page?
- finding whether request is for post, and post id
- Anonymous Postings
- Do widget options need to be escaped widget()?
- Is there any W3C compatible Share & Follow plugin?
- Any built-in function to associate a post to category through a plugin?
- Does any one have Idea to get these functionalities with the plugin wp-multi-network
- How to hide some section in WordPress under Post
- Display post lists in 2nd paragraph
- Can’t delete Draft Post [closed]
- Matching Chapters to a Custom posts [closed]
- Disable woocommerce cookies and delete cart data automatically
- WordPress comments not appearing in blog posts, likely because of Redux template. Could I fix this with a plugin that adds a comment form as a block? [closed]
- className not populating in custom block
- WordPress display breadcrumbs using Yoast plugin [closed]
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Outbound link autometic converted into linkdirect , and not opening
- Run plugins only on certain pages
- Display by Category in Admin
- Overide plugin files from child theme (/inc/ ) folder
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- wp_generate_attachment_metadata is creating an empty array
- custom payment gateway in woocommerce failed to connect to remote api server
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- Display encrypted content on my website
- Two problems on my WordPress installation [closed]
- Post category with counts been display like a menu
- Post custom Data value in The Events Calendar plugin [closed]
- Send reply with pre-prepared answers
- posts comments goes to trash
- Contributive page where people logged in can write
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Save custom attributes of product in woocommerce
- Calling an attribute from a plugin shortcode
- Best place for short bio,image and button [closed]
- Excerpts on category page
- How to pull email and name from Flamingo plugin