No “Add New” Button. How to add new theme?

In my case, the button was missing because it was a multisite install. The Add New button appears only when you go to top bar -> My Sites -> Network Admin -> Themes. From there, you can add new themes and enable them for the rest of the network.

Dash or underscore in theme folder name?

In short, there is no well defined convention for naming a theme’s directory, and all of the following are valid (among others): my_wordpress_theme my-wordpress-theme (empirically the most popular option within the ecosystem) MyWordPressTheme mywordpresstheme (what the default themes use) Details The WordPress PHP Coding Standards Handbook states that filenames should be all lowercase and hyphen-separated. … Read more

Undefined offset: 0 in > […] /wp-includes/capabilities.php on line 1067

You have found a bug in Genesis. Your Xdebug stack trace fingers the culprit as the genesis_save_custom_fields() function which calls current_user_can() with a singular capability (edit_post and edit_page) which also requires an additional argument, in this case the post ID which is missing. current_user_can() calls has_cap() which calls map_meta_cap() which does a switch statement on … Read more

what the best way to include images from the template’s images folder?

The easiest and simplest way to do it is define a unique variable in your theme’s functions.php file. Such as: <?php $theme_name_images = get_bloginfo(‘stylesheet_directory’) . ‘/images/’; ?> No need for classes as a previous answer suggested. EDIT: It should be get_bloginfo, instead of bloginfo(), as Viper007Bond kindly pointed out.

How can I version the main CSS file?

Style.css is required for your WordPress theme. That’s where WordPress gets the theme name and meta information for the Appearance >> Themes menu from. That said, you don’t actually have to use style.css in your theme at all. I know of several readily available themes that don’t use it, and I only use it in … Read more

Show different theme for admin?

I just wrote this quick plugin and it seems to work. Let me know if there is a better way. <?php /* Plugin Name: Theme Switch if Admin Description: Display different theme to user if logged in as admin Author: Kyle Barber */ add_filter(‘template’, ‘change_theme’); add_filter(‘option_template’, ‘change_theme’); add_filter(‘option_stylesheet’, ‘change_theme’); function change_theme($theme) { if ( current_user_can(‘manage_options’) … Read more

Different template of products for specific category. WooCommerce

You could change your single-product.php to just be a redirect to the correct template depending on what product category the current product it. To do so you’d copy single-product.php to your theme’s woocommerce folder. Rename it to single-product-default.php or anything. Create another copy and call it single-product-coffee.php. You can make whatever changes you’d like to … Read more

How to set thumbnail image for a (child) theme

Create image file in PNG Format having name screenshot.png and save it in themes root folder.The recommended image size is 880×660. Even recommended image size is 880×660 though it will only be shown as 387×290 but the double-sized image allows for high-resolution viewing on HiDPI displays. For more information see this page. If you don’t … Read more