Adding HTML to the Header, Screws up in IE7

Write a stylesheet just for ie7 and link it in wordpress like so: <!–[if IE 7]><link rel=”stylesheet” type=”text/css” href=”https://wordpress.stackexchange.com/questions/4324/<?php bloginfo(“stylesheet_directory’); ?>/css/ie7.css” /><![endif]–> in the file add this #header table {float:right;} #header table tr td p {margin-top:45px;}

Looking for methods to Check if File Exist

There’s a lot of ways you could go with this. I might enqueue the style in your theme’s functions.php dependent on a file_exists() check. $your_css_file_path = “/path/to/file”; if ( file_exists($your_css_file_path) ) { wp_register_style(‘your_theme_stylesheet’, $your_css_file_path); wp_enqueue_style( ‘your_theme_stylesheet’); } Here’s the relavent core source.

What parameter should I pass to wp_enqueue_style to depend on the themes stylesheet?

First issue – you have dependency backwards. Depending on something means loading after dependency, while you want earlier. Second issue – theme’s stylesheet doesn’t actually use enqueue, it is usually codded directly in header.php file of theme. And since it seems to come before wp_head() call – you have no hook to ensure your stylesheet … Read more

Custom post type and body_class: Remove “blog” class

You can use body_class filter to check if you are on your custom post type, and if so then just remove the blog class like this: function remove_blog_from_cpt_classes($classes, $class){ global $post; if ($post->post_type != “products”){ return $classes; }else{ foreach($classes as &$str){ if(strpos($str, “blog”) > -1){ $str = “”; } } } return $classes; } add_filter(“body_class”, … Read more

How do I write into a file (css)

What’s wrong with saving CSS to the database? That is the correct approach. And that way, you can simply output the options to a function, which can be enqueued properly, using wp_print_styles, and entirely avoid file operations/writing to .css files.

WordPress override bloginfo variable

For the example you mentioned, you can add a filter to the stylesheet_directory hook add_filter(‘stylesheet_directory’,’change_stylesheet_dir’) ; function change_stylesheet_dir($stylesheet_dir, $stylesheet, $theme_root) { # do stuff – change the stylesheet directory $new_stylesheet_directory = ‘http://mysites.com/hello/’; return new_stylesheet_directory ; } For any of the other parameters for bloginfo, you can look at the code for for bloginfo, which is … Read more

How to load parent theme style.css?

At the top of your child themes style.css add: @import url(“../twentyeleven/style.css”); Obviously replace twentyeleven with your parent themes folder. 2016 – This practice has now been replaced by declaring the ‘Template’ in your theme stylesheet header: Template: twentyfifteen https://codex.wordpress.org/Child_Themes

How do I include background images in my stylesheets in a plugin?

Just add a STYLE tag in ‘wp_head’. // Anonymous function, PHP 5.3+, extract function for 5.2 add_action(‘wp_head’, function(){ echo ‘<style type=”text/css”>’; // Add background style here echo ‘</style>’; }); Add this in your functions.php. Don’t stuff too much CSS in it, just the dynamic bg image you need. It’s not the easiest thing to create … Read more

remove everything from wp_nav_menu

You can use another walker than WordPress pre-build one. Add this to your functions.php file in the theme: class Clean_Nav_Walker extends Walker { var $tree_type = array( ‘post_type’, ‘taxonomy’, ‘custom’ ); var $db_fields = array( ‘parent’ => ‘menu_item_parent’, ‘id’ => ‘db_id’ ); function start_lvl(&$output, $depth) { $indent = str_repeat(“\t”, $depth); $output .= “\n$indent<ul class=\”sub-menu\”>\n”; } … Read more