Articles of styles

How to style the last post on the front page different than the others?

I would like the last post of the front page to be styled differently than the rest, how could I achive this? This is the index.php <?php get_header(); ?> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, get_post_format() ); ?> <?php endwhile; ?> <?php else […]

Load plugin scripts and styles only on plugin page

Hello wordpress users, I’m stuck with a problem while running 2 self made WordPress plugins. I’ll use the following code : define(‘PLUGIN_URL’, plugin_dir_url( __FILE__ )); add_action( ‘admin_enqueue_scripts’, ‘plugin_load_js_and_css’ ); function plugin_load_js_and_css() { wp_register_style( ‘plugin.css’, PLUGIN_URL . ‘plugin.css’, array()); wp_enqueue_style( ‘plugin.css’); wp_register_script( ‘plugin.js’, PLUGIN_URL . ‘plugin.js’, array(‘jquery’)); wp_enqueue_script( ‘plugin.js’ ); } } But it’s loading this […]

To enqueue or not to enqueue

What is the best way to link to a CSS file in WordPress? Method 1: Use the following whenever needed <link href=”<?php echo get_template_directory_uri(); ?>/my-style.css” rel=”stylesheet” type=”text/css” /> Method 2: Use enqueue as follows add_action(‘wp_enqueue_scripts’, ‘load_my_style’); function load_my_style () { wp_register_style(‘my-style’, get_template_directory_uri() . ‘/my-style.css’); wp_enqueue_style(‘my-style’); } Please also let me know why a certain method […]

How do I load custom scripts and styles for a page?

Different pages often need different set of scripts and styles for them. I use functions.php and construction like this to load scripts and styles: function load_assets() { wp_enqueue_style( ‘styles’, get_template_directory_uri() . ‘/css/styles.css’); wp_enqueue_script(‘main-js’, get_template_directory_uri() . ‘/js/main.js’); } add_action( ‘wp_enqueue_scripts’, ‘load_assets’ ); I know I can put some condition here like this: is_page() but is there […]

Adding Custom Styles to the MCE dropdown toolbar

I am using the following code to add style drop downs the mce toolbar, I want to be able to add a h1 element with the drop down but my code isnt working, I have tried a couple of different ways but it doesnt work, I got this code form here add_filter( ‘mce_buttons_2’, ‘my_mce_buttons_2’ ); […]

How to implement different color schemes in your themes

This question is for theme developers. I know how to use the settings API to gather input data, but I was wondering what’s the best way include the styles. Let’s say you have 4-5 versions of the design, each with its own CSS rules and images. Options: You stuff all the CSS in style.css and […]

use add_action('wp_head') in a widget for generating dynamic CSS styles

I have been working on a ‘Custom Pop Links’ widget for use in a theme which is ready for distribution. User can change the color of a link using a color picker inside widget. Untill now, I used inline styles for applying the selected color to the link. However, I want to use media queries […]

Use a higher than 230px logo image with 2013 theme

UPDATE: My question is not offtopic, because WordPress crops the logo image and not just CSS. I’m trying to use a 4724 × 2362 png image as a site logo at the top of a WordPress website with the stock Twenty Thirteen theme. By default the image height is cropped (here fullscreen) and you can’t […]

How to automatically highlight syntax of code in a post?

I post my codes from different programing languages. Now, I want to highlight syntax of codes with different colors. But, doing it manually is time consuming. Is there any plugin or method which could do this automatically? Strictly, it should be done in CSS way.

How can I get a list of all enqueued scripts and styles?

I’m creating a plugin and I want to get the list of all scripts and CSS used by other plugins. This is my function: function crunchify_print_scripts_styles() { $result = []; $result[‘scripts’] = []; $result[‘styles’] = []; // Print all loaded Scripts global $wp_scripts; foreach( $wp_scripts->queue as $script ) : $result[‘scripts’][] = $wp_scripts->registered[$script]->src . “;”; endforeach; […]