When is get_template_part() preferable to simply using the template.php files?

A recommended approach for using get_template_part would be for including bits of code that would otherwise be repeated frequently in all your templates. Like if you had conditionals defined within your loop that you wanted to include in archive.php, search.php, single.php etc. It also allows child themes to override that file and include additional more … Read more

List of all theme customizer control types?

Have a look in the source: http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-customize-control.php Basic control types: text checkbox radio select dropdown-pages Also some advanced control types (as-described by Otto): WP_Customize_Color_Control – extends the built in WP_Customize_Control class. It adds the color wheel jazz to places where color selection is needed. WP_Customize_Upload_Control – This gives you an upload box, for allowing file … Read more

Display single product attribute value on Shop page (Woocommerce)

Just use global $product then use get_attribute() method of that product object, like below- $size = $product->get_attribute( ‘pa_size’ ); And you can also get that by below code- global $product; $size = array_shift( wc_get_product_terms( $product->id, ‘pa_size’, array( ‘fields’ => ‘names’ ) ) ); Rememeber you need to use must the global $product.

Custom Post Types on Category Pages

For custom post types with custom taxonomy you can make a template for that taxonomy. Your custom taxonomy template would be named taxonomy-{taxonomy}.php. For example, if your taxonomy was called “cooking-categories” you would name your file taxonomy-cooking-categories.php. More information on template files for special taxonomy archives can be found in the codex here: http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display

Custom Search Query

1) You can use the template search.php and searchform.php as your starting points. Creating a Search Page Codex 2) As far as the custom query goes, you can use pre_get_posts hook to test if you’re on a search page, then you get $_GET your values, edit your query accordingly. Action Reference – pre_get_posts There are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)