Check if the following works for you. Just adapt the is_single() to is_singular(‘custom-post-type’) if you want this on a single custom post type template specifically. Hope this helps.
function bootstrap_scripts_styles() {
wp_enqueue_style('custom-style',get_template_directory_uri() . '/bootstrap.css');
$custom_css = ".intro { background: red; }";
wp_add_inline_style( 'custom-style', $custom_css );
}
function enqueue_inline_style( $query ) {
if ( $query->is_single()) {
add_action( 'wp_enqueue_scripts', 'bootstrap_scripts_styles' );
}
}
add_action( 'pre_get_posts', 'enqueue_inline_style' );
edit: obviously just enqueue the main stylesheet separately.
Related Posts:
- Outline effect to text
- Vertically align text within a div
- Insert image after each list item
- How to add a color overlay to a background image?
- Change color of PNG image via CSS?
- In CSS what is the difference between “.” and “#” when declaring a set of styles? [duplicate]
- Transitions on the CSS display property
- How to completely remove borders from HTML table
- How to fix a footer overlapping content?
- What is element.style and why is it overriding my css settings?
- Overflow Scroll css is not working in the div
- CSS Div width percentage and padding without breaking layout
- CSS Box Shadow – Top and Bottom Only [duplicate]
- How to place Text and an Image next to each other in HTML?
- What does the “~” (tilde/squiggle/twiddle) CSS selector mean?
- CSS background-image – What is the correct usage?
- Set bootstrap modal body height by percentage
- Overflow-x not working
- How can I fill a div with an image while keeping it proportional?
- Inbuilt style for jquery-ui-datepicker
- Why is style.css not being enqueued?
- Remove top admin bar
- How to add a class to ul tags created by the WordPress editor Tinymce?
- Using theme options to change link colours
- When enqueing a stylesheet, is it possible to remove the type attribute? [duplicate]
- Collapsible button inside a ul list does work in jsfiddle but not in WP
- How to make float element in tinymce
- How to add 10 different css class to posts
- wordpress in wamp lan doesn’t load css
- JavaScript added as link/stylesheet
- Is there a default style.css
- How to get a value for admin css color either gray or blue
- Change color of audio player depending on user role
- Adding external stylesheet after ALL other styles
- How can I use PurifyCSS to clean WordPress style.css?
- WordPress Twenty Fourteen Theme Sidebar
- WordPress CSS doesn’t update
- Removing Title From Links to Site
- create bootstrap columns inside editor group block
- Website scroll not working on SAFARI
- Admin pages missing css
- Old Site displays on Mobile View, not New Site
- No responsive design is displayed
- Child theme CSS not applying to element
- How to Style Primary Menu with Active Class
- Set 3 iframes in a row
- Google yolo one tab signup plugin avilable in wordpress? [closed]
- Make CSS Changes To Only Affect Mobile Browser [closed]
- Disable File Editing function
- HTML email sent with wp_mail shows plain text
- Change Header Image on Blog Post for Mobile View
- adding the_custom_logo(); to header
- Add second background-image on hover
- Common page width? [closed]
- WordPress Rest Api access the header and extract stylesheets URL
- Login validation on wordpress
- How to create CSS Counters for Comments (depth 5)?
- Navbar bg to overflow to section below (updated)
- Add top parent page id to body class
- WordPress default theme CSS version problem and not loading
- Penscratch 2 – changing color of the main block
- How can customized CSS on WordPress highlight the blog title in white when it’s not intended?
- Are there any CSS classes for the wordpress colours?
- Set different css stylesheet for specific pages [duplicate]
- Desktop is class List and Mobile is class Grid
- Include ElementorPro css into WordPress custom page
- Customizing the CSS for the post/page editor?
- My Child Theme CSS Isn’t Working
- Remove dashicons.min.css conditionally
- Remove Parent Style on Carousel
- current menu item hover not working?
- how to load basic wordpress css
- Fonts are not applying
- Text Not Wrapping Around Right Floated Image [closed]
- header background color changed after drop & import database in phpmyadmin
- Add class when more page is visited
- How do I make a child theme’s style.css load after plugin css?
- Css style removed but still showing via CDN even after clearing browser cache and purging all caches for site
- How to include backend buttons css on frontend?
- vertical menu bar css
- After upload on server 404 on all pages, no css
- Managing large CSS files [closed]
- How would I use a media query to make my entire theme responsive or fluid? [closed]
- Clear white line off page [closed]
- Images at the same vertical position in multiple columns
- css .active dropdown selects all links
- background changed after WordPress update
- How to make this splash page responsive
- Menu is not styled properly and footer as well [closed]
- Footer in middle of page in different browers [closed]
- Add Quicksand for mobile devices
- Hiding site title for Twentyfifteen sidebar on (responsive) desktop display size
- Why is the image in div not displayed in full-size?
- How do I add JS and CSS to WP (Flatsome)
- Narrow paragraph block aligned to left of “wrapper”
- Transparent Overlay for Gravity Forms Ajax Spinner
- Remove the main title, but only from the main page
- aos properties ‘invalid’ and not recognised when included as a css class [closed]
- Customize margin between paragraphs using the Gutenberg Style editor
- How to remove automatically added custom style tag?