theme path in javascript file

What you’re looking for is wp_localize_script function. You use it like this when enqueing script wp_register_script( ‘my-script’, ‘myscript_url’ ); wp_enqueue_script( ‘my-script’ ); $translation_array = array( ‘templateUrl’ => get_stylesheet_directory_uri() ); //after wp_enqueue_script wp_localize_script( ‘my-script’, ‘object_name’, $translation_array ); In your style.js, there is going to be: var templateUrl = object_name.templateUrl; …

Hide prices and checkout functionality in woocommerce

luckily woocommerce has many hooks, this removes prices and buttons: remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ ); remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 ); remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 ); remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 ); you can dig into content-product.php and content-single-product.php if you need to remove more stuff. I can imagine there’s more than just the prices/buttons you want to … Read more

Does WordPress work without a theme?

I think there’s a song for that: “Imagine there’s no theme. It’s easy if you try. No hell below us. Above us only sky …” 😉 So in that imaginary dream: you can still fetch the RSS feeds from your site: example.com/feed/ you can still login to your backend: example.com/wp-login.php you can still access the … Read more

how to add version of style.css in wordpress

Version number is a parameter of wp_enqueue_style(). As per the Codex, here are all the parameters that wp_enqueue_style accepts. wp_enqueue_style( $handle, $src, $deps, $ver, $media ); So for example to load a stylesheet with a version number you’d do the following: function wpa_90820() { wp_enqueue_style(‘my-styles’, get_stylesheet_directory_uri() .’/my-styles.css’, array(), ‘1.0’ ); } add_action(‘wp_enqueue_scripts’, ‘wpa_90820’);

How do I turn off self-closing tags for markup in WordPress (for HTML5, or HTML4, for example)?

Line breaks are added by wpautop(), not wptexturize(). wpautop() is also the function that automatically adds paragraph tags. You’re better off fixing the <br />‘s than you are replacing the filter. Since wpautop() runs at priority 10, you can just hook in after that and fix it. add_filter( ‘the_content’, ‘html5_line_breaks’, 25 ); function html5_line_breaks( $content … Read more

Where can I learn to create my own theme?

There are many different ways to learn to create your own theme. First, there’s the “official” WordPress Codex on Developing Themes, but I’d say that it is more of a reference than a tutorial. Another approach and one I like a lot is to read some of the better tutorials about WordPress Theming on the … Read more

How to add custom css file in theme?

I usually add this piece of code if I want to add another css file <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/58351/<?php bloginfo(“template_url’); ?>/css/my_custom_css.css” type=”text/css” media=”screen” /> I believe the theme makers want to retain as much as possible of the theme’s layout design. So a custom css file doesn’t hurt much. I think it’s more of a support … Read more