WooCommerce change number of columns in the frontpage

You didn’t say what snippets you’ve actually tried, but according to the docs, you can filter loop_shop_columns like so: function wpa65503_woo_shop_columns( $columns ) { return 3; } add_filter( ‘loop_shop_columns’, ‘wpa65503_woo_shop_columns’ ); tested and working for me with Twenty Eleven theme. EDIT – this is the particular line in the default content-product.php template file that makes … Read more

wp nav menu: add attributes to menu items [duplicate]

You can use a Custom Walker to add attributes to the menu items. Basically, you add a parameter ‘walker’ to the wp_nav_menu() options and call an instance of an enhanced class: wp_nav_menu( array ( ‘menu’ => ‘main-menu’, ‘container’ => FALSE, ‘container_id’ => FALSE, ‘menu_class’ => ”, ‘menu_id’ => FALSE, ‘depth’ => 1, ‘walker’ => new … Read more

Placing assets for external use

I have used symbolic links for convenience for awhile on a dev server but they are not 100% reliable as some PHP functions will return the filesystem path of the target instead of the path to the symlink itself. The most notable example (though not really a function) is the magic constant __FILE__. (Also https://bugs.php.net/bug.php?id=46260) … Read more

How to center oEmbedded content

After some Googling, I found a solution that was originally done for a Twitter embed, but I modified it to work with all oEmbed contents. Keep in mind that for this to work on existing posts, you’ll need to do an “update” for the oEmbed content to refresh from the cache. add_filter(‘oembed_result’,’center_oembed’,10,3); function center_oembed($html, $url, … Read more

Include user defined styles without including wp-load

If you are going to enqueue a stylesheet you should be using wp_enqueue_scripts not wp_print_styles, but you are in a bit of a gray zone between doing things “WordPress-ie” and doing things correctly for performance. The “WordPress-ie” way is to enqueue a stylesheet, but from a performance standpoint you are loading an additional resource and … Read more

JavaScript added as link/stylesheet

wp_enqueue_script is for… scripts. You want wp_enqueue_style (and wp_register_style) for stylesheets. Also note that you can enqueue as many things as you’d like in a single function, no need to create a separate function for each. You can also pass all the same arguments to enqueue as you do to register, no need to register … Read more

wordpress in wamp lan doesn’t load css

finally i solved it…this was a very annoying problem! just enter your db and change in wp_option: – siteurl: from localhost server’s lan ip – home: from localhost server’s lan ip that’s it! 🙂

De-registering a CSS file leaves it in the queue

To properly and completely remove a style, you need to deregister(wp_deregister_style()) and dequeue(wp_dequeue_style()) it. Dequeueing will remove the style from the array in the $wp_styles variable, deregistering the style will remove the stylesheet from being printed add_action( ‘wp_enqueue_scripts’, ‘my_deregister_styles’, 100 ); function my_deregister_styles() { wp_dequeue_style( ‘genericons’ ); wp_deregister_style( ‘genericons’ ); }