Hot answers tagged

18

Theme stylesheets aren't usually enqueued, they're normally loaded using.. <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> So naturally you don't see them(it) in the styles array.. You can of course(if you prefer) use an enqueue instead.


10

do_action doesn't quite work like that. When you call do_action('crunchify_print_scripts_styles') WP looks at its list of registered actions and filters for any that are attached to a hook called crunchify_print_scripts_styles and then runs those functions. And you probably want to remove this: add_action( 'wp_enqueue_scripts', '...


7

When you register a plugin option page you get a hook from the registration function: $hook = add_menu_page( 'T5 Demo', // page title 'T5 Demo', // menu title 'manage_options', // capability 't5-demo', // menu slug 'my_render_page' // callback function ); Use this hook to enqueue the scripts and styles: add_action(...


5

Technically speaking, there is no "standard" Post Format. Rather, "standard" is simply the default - as in, no Post Format type is defined. If no Post Format type is defined, get_post_format() simply returns null. I would suggest re-factoring your code above, and re-naming your icon images using the exact Post Format string. That way, you could do: <...


5

The background is a option. You can set colors and also images. See in the Administration area, Appearance --> Background Also you can use the Live Preview link on the theme and customize the background and other otpions.


5

You could use wp_print_scripts and wp_print_styles actions to timely and properly access to enqueued scripts and styles, as these actions are the last events before scripts and styles are included in the document and, because of that, the last event where modifications on $wp_styles or $wp_scripts could have effect on styles and scripts included in the ...


3

I would put all the common css in the theme's style.css, and create separate stylesheets for the color options. I would also put color options in their own folder with the images for that style. This way you can keep the filenames the same between color options to make maintaining the code a little easier. If you wanted to separate common.css from style....


3

You’ll a need a real CSS parser like this one to filter the CSS. Regular expressions or simple string replacements are not safe enough.


3

You can change the order of the scripts but can't have one script load before anything else. The HTML 5 enabling script is IE conditional so you probably don't want to use wp_enqueue_script as it would load for all browser users which isn't necessary. It's ok to hard code it in your themes header. Even Twentyeleven does it this way. Also there is nothing ...


3

When your users really need 30 lines of custom CSS, your theme is flawed. Create a set of predefined styles instead (dark and light scheme, sans and serif fonts etc.) and prepare your main stylesheet for these cases. You can hook into body_class then and add the classes you need to get these styles. Adjustments for your users should be very minimal then. ...


3

Method 2 You can enqueue all of your stylesheets form the same place even controlling where the stylesheets load by means of template conditionals, which is convenient and prevents a lot of mess in your <head>. You can remove enqueued stylesheets if you need to via a plugin, for example. Enqueued stylesheets are child theme friendly as they can be ...


3

h2 and h3 are not html classes, they are html tags. That said, does not exists a default html tag for the widgets, because the format used to output widgets title is set when the sidebar is registered (look at 'before_title' argument). So how title is shown is theme related and sidebar related, does not depends on widgets. An easy way to change the html ...


3

The filter responsible for adding these characters is wptexturize, you can remove it using remove_filter. remove_filter( 'the_content', 'wptexturize' ); remove_filter( 'the_excerpt', 'wptexturize' );


3

Enqueueing styles within a function as you have done is the standard best practice for WordPress, whether you are building a theme or creating a child theme. And as mentioned, you can enqueue both styles and scripts from within one function, http://marker.to/65CMY3.


3

Yes, you may add conditional tags to the wp_enqueue_scripts action. See the examples below: function load_assets() { wp_enqueue_style( 'styles', get_template_directory_uri() . '/css/styles.css'); // loads on any 'page' post type if( is_page() ){ wp_enqueue_script('main-js', get_template_directory_uri() . '/js/main.js'); } // only ...


3

The fault is from the following code, change the colors or remove it. .xoouserultra-wrap a.xoouserultra-button:hover, input[type=submit].xoouserultra-button:hover, input[type=submit].xoouserultra-button:focus, input[type=button].xoouserultra-button:hover, input[type=button].xoouserultra-button:focus, .xoouserultra-wrap a.xoouserultra-button:active, input[...


3

Solved it... In my functions.php I should have put: array( 'title' => 'Hidden Element', 'inline' => 'span', 'classes' => 'hiddenElement', 'wrapper' => false, ), not array( 'title' => 'Hidden Element', 'block' => 'span', 'classes' => 'hiddenElement', ...


2

I solved this by creating 2 functions to split the_content() in a before and after-function: class MyClass { /** * Echo the content before the <!--more--> tag */ public static function getContentBeforeMore() { global $more; $more = false; the_content(false); $more = true; } /** * Echo ...


2

using: http://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior and the $strip_teaser parameter: http://codex.wordpress.org/Function_Reference/the_content#Usage in single.php, replace <?php the_content(); ?> with: <?php if( strpos(get_the_content(), '<span id="more-') ) : ?> <div class="before-...


2

Try this code instead of your block: <?php $format = get_post_format(); if ( false === $format ) { ?> <img src="<?php bloginfo('template_url'); ?>/post-icons/standard.png" alt="standard" /> <?php } ?>


2

The recommended way to do it is by enqueue-ing style.css in the functions.php of the theme. Add this to functions.php /** * Load CSS and JS the right way */ function myprefix_load_css_and_js() { wp_enqueue_style( 'style', get_stylesheet_uri() ); } add_action( 'wp_enqueue_scripts', 'myprefix_load_css_and_js' ); You can refer this in the WordPress ...


2

put wp_enqueue_script() in your shortcode handler. add_shortcode('myshortcode', 'my_shortcode_handler'); function my_shortcode_handler($atts) { wp_enqueue_script('my-script', plugins_url('my-script.js', __FILE__), array('jquery'), '1.0', true); // actual shortcode handling here return "bacon flavored shortcode here"; } this definitely loads the ...


2

Your theme's body_class can be used to target specific pages: body.home /* front and subsequent pages */ body.paged /* any page *except* front page */


2

The best approach I found was to incorporate CSSTidy into my plugin. I took a page from JetPack which has a Custom CSS feature. JetPack's CSSTidy implementation is contained in the Jetpack_Safe_CSS class as function, filter_attr. I couldn't entirely figure out why JetPack was nesting the user entered CSS inside a 'div' element prior to parsing, but after ...


2

First of all Check If you disabled the visual editor from your profile page. [See the Screen Shot] You ned to uncheck the box - Visual Editor, the option is located in User's Edit Profile Page. UPDATE - 1 2 - You might have been disabled the Kitchen Sink, To enable it Click on small button available in visual editor (Right most button) icon or Press - ...


2

You could use the wp_head hook and inject your <style> tag directly into the <head>. Note: make sure you're firing the wp_head() function in your template (which you should be doing already). add_action('wp_head', 'random_background_image_wpse_83275'); function random_background_image_wpse_83275() { $images = array( '/path/to/image1.jpg', ...


2

If it's purely for setting the style of the text you may want to use JavaScript/jQuery instead. Here's a quick sample that would replace all instances of "ipsum" with <span class="red">ipsum</span> And the full code: // Find text in descendents of an element, in reverse document order // pattern must be a regexp with global flag // function ...


2

The CSS comes from wp-includes/css/buttons.css. Do not change this this file; it will be overridden during the next update. Create a separate plugin instead, or add some custom code to your theme’s functions.php, and hook into login_head: add_action( 'login_head', function() { ?> <style> .button { background: red !important; } </style&...


2

If your theme uses wp post class function post_classes($classes) { global $post; $customMetaVariable = get_post_meta( $post->ID, 'customMetaName', true ); if($customMetaVariable == 'desiredCustomMetaValue'){ $classes[] = 'cssClassName'; return $classes; } } add_filter('post_class', 'post_classes'); then in your style....


2

In short: make sure that the Jetpack plugin is installed and enabled, and also that the Jetpack Lite plugin is not enabled. I found out that Edit CSS is provided not by WordPress itself but by the plugin Jetpack. Jetpack was still installed; I had a Jetpack menu right below Dashboard. But when I opened it, I saw only two items, “WordPress.com Stats” and “WP....


Only top voted, non community-wiki answers of a minimum length are eligible