How can I included CSS to a page or a shortcode? [closed]

Simply follow the link to the has_shortcode() documentation in the last answer to the duplicate question. There you’ll find: function custom_shortcode_scripts() { global $post; if ( is_a( $post, ‘WP_Post’ ) && has_shortcode( $post->post_content, ‘custom-shortcode’) ) { wp_enqueue_script( ‘custom-script’); } } add_action( ‘wp_enqueue_scripts’, ‘custom_shortcode_scripts’); For styles this would be: function custom_shortcode_styles() { global $post; if ( … Read more

How to override Gutenberg admin CSS

To override Gutenberg’s styles you need to add your own stylesheet. So hook into enqueue_block_editor_assets and then add your own stylesheet in which you target the selectors you wanna override. In the following example I placed a stylesheet in a custom theme’s assets/ folder. functions.php: // Add backend styles for Gutenberg. add_action(‘enqueue_block_editor_assets’, ‘gutenberg_editor_assets’); function gutenberg_editor_assets() … Read more

Style classic editor buttons

You can add CSS to the admin area of WordPress using the [admin_head][1] hook add_action(‘admin_head’, ‘my_custom_admin_styles’); function my_custom_admin_styles() { echo ‘<style> #qt_content_center { color: red; } </style>’; } Note: Alternatively, you could add a stylesheet using the same function. Edit: Adding custom stylesheet to WP Admin. add_action( ‘admin_enqueue_scripts’, ‘load_admin_styles’ ); function load_admin_styles() { wp_enqueue_style( ‘admin-styles’, … Read more

Write text below a specific part of a sentence

Maybe you could find the x/y-position of the span with Javascript and position another div with an increased y-position? I don’t think there will be an out-of-the box css solution to this problem. Here is a quick example: <!DOCTYPE html> <html lang=”en”> <head> <meta name=”viewport” content=”width=device-width” /> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> <style> p {font-size: … Read more

Put CSS inside a PHP file and include it the right way

You might try conditional classes instead. In your regular “style.css” file you would include both classes: .theme-header-title.green { color:green; } .theme-header-title.blue { color:blue; } (Tip 1: avoid !important, just use a more specific style if needed – for example, h1.theme-header-title.green.) Then in your HTML, which is likely in your “header.php” file, you’d use the Customizer … Read more

Enable specific CSS Code for Visitors and specific Roles

You can add custom css on your html header using wp_head hook action & checking your current User Role add_action(‘wp_head’, ‘add_css_of_current_specific_user_role’); function add_css_of_current_specific_user_role() { /*Check Current User is Login*/ if ( is_user_logged_in() ) { $user = wp_get_current_user(); /*Check Current User Role*/ if (in_array(‘visitor’, $user->roles)) { ?> <style> // Some CSS </style> <?php } } }

removing my underline from hyperlinks

The code you said you tried, a {text-decoration:none;}, should work. Using, a {text-decoration:none!important;}, should definitely work or using an inline style, like in the <p> tag would take precedence over the stylesheet. The more correct way would be to either edit the CSS, ideally in a child theme, and apply your own styling. Using !important … Read more