How to target first img in every wordpress post with CSS [closed]

Firstly i would say this is off-topic here as it purely relates to css/js, but let me try to give some pointers. Here you markup is : <article> <header></header> <div> …. <p><img class=”align-center” src=”https://wordpress.stackexchange.com/questions/225091/path/to/img1″></p> …. <p><img class=”align-center” src=”path/to/img2″></p> …. </div> </article> first-of-type means selecting the first child of the selector parent. In the above markup … Read more

I want to include my style.css in function.php file?

You are calling the function wrong. You have not given your filename, just a directory. From the codex wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media=”all” ) so in your case, you should enqueue like so add_action( ‘wp_enqueue_scripts’, ‘wpse_my_style’ ); function wpse_my_style(){ wp_enqueue_style( ‘my-style’, get_stylesheet_directory_uri() . … Read more

De-registering parent style sheet css recommended?

This is not a very smart thing to do. As you noted yourself, you’ll have issues when the parent theme is updated. Moreover, the parent theme might have secondary stylesheets that depend on the parent style (third parameter in wp_enqueue_style). There might be javascript that assumes it’s there. In other words: it will take very … Read more

Is it possible to use the featured image of a page as a css background without inlining?

There’s two possible options in creating a stylesheet from a dynamically generated value. The first options is Inline stylesheet, as follows: <div id=”hero” style=”background-image: url(<?php // TODO retrieve image here. ?>); “> </div> And the second options is to use an Internal stylesheet, and possibly the best solution out of both. Using stylesheet internally requires … Read more

Unable to load stylesheets and scripts to plugin settings page

The way to go was to use wp_enqueue_style() and wp_enqueue_script functions when admin_enqueue_scripts hooks. To register styles and scripts with wp_register_style and wp_register_script respectively is optional, but has some good advantages as nicely explained here. Here’s the working script: <?php /* Plugin Name: Awesome Slide Show */ // admin_init // ************************************************************************************************ function wp_ss_plugin_admin_init_cb() { // … Read more