wp add inline style in loop

If grid_init() runs inside the Loop, then it executes after the page head and after the associated hooks– wp_head, wp_enqueue_scripts, etc. PHP executes line by line in sequence, so if you miss a hook you just missed it. You can’t go backwards. The script/style enqueueing subsystem does have to ability to put things int he … Read more

How to add php stylesheet to admin section instead of admin_head hook

If you enqueue your style sheet first you should be able to use wp_add_inline_style afterwards. function custom_style() { wp_enqueue_style(‘your_css’, plugin_dir_url( __FILE__ ) . ‘style/your_css.css’ ); $bg_color = get_option(‘custom_color’); $custom_css = ” body { background-color: {$bg_color}; }”; wp_add_inline_style( ‘your_css’, $custom_css ); } This is not tested (just written from mind) and I have never used it … Read more

Unable to load stylesheet via wp_enqueue_style

Yo have not opened the php tag correctly in the beginning of your snippet. try adding at least one space after <?php and right before the first //: <?php // Load the theme stylesheets function theme_styles() { // Load all of the styles that need to appear on all pages wp_enqueue_style( ‘main_css’, get_template_directory_uri() . ‘/style.css’ … Read more

Different styles on multiple pages

You can use elseif to check another page template and you can go on like this. if ( is_page_template(‘page-templates/page-1.php’) ) { wp_enqueue_style( ‘sentiencesentient-layout-style’ , get_template_directory_uri() . ‘/layouts/style1.css’); } elseif ( is_page_template(‘page-templates/page-2.php’) ) { wp_enqueue_style( ‘sentiencesentient-layout-style’ , get_template_directory_uri() . ‘/layouts/style2.css’); } elseif ( is_page_template(‘page-templates/page-3.php’) ) { wp_enqueue_style( ‘sentiencesentient-layout-style’ , get_template_directory_uri() . ‘/layouts/style3.css’); } elseif ( is_page_template(‘page-templates/page-4.php’) … Read more

custom template – override plugin template in child theme – issue with scripts

Please Provide Proper path to enqueue scripts and styles Example- function theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ); then it will work fine