How to assign custom template to specific products in Woocommerce?

If the changes you need are strictly CSS, you can add the category names as classes to the body_class via the body_class filter. add_filter(‘body_class’,’wpa76627_class_names’); function wpa76627_class_names( $classes ) { if( is_singular( ‘product’ ) ): global $post; foreach( get_the_terms( $post->ID, ‘product_cat’ ) as $cat ) // maybe you want to make this more unique, like: // … Read more

Need oop for wordpress theme? [duplicate]

It will be better if you code theme in OOPS(Object Oriented Programming) because OOPS provides following benefits over normal/procedural oriented programming. Benefits of Object Oriented Programming Modularity: The source code for a class can be written and maintained independently of the source code for other classes. Once created, an object can be easily passed around … Read more

How to add menù section to my WordPress template?

You need to edit functions.php andding the following line <?php register_nav_menu( ‘primary’, ‘Primary Menu’ ); ?> Then go in admin section Apearence-Menus and create one menu In the header replace <?php wp_list_pages(‘title_li=&depth=1’); ?> for example (the primary menu) with: <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’)); ?> more details for nav_menu here

Color Options from Theme Customizer API not returning via get_theme_mod()

If your settings are stored as Theme Mods, rather than as a Settings API option, then you need to pass the appropriate value to the type parameter to $wp_customize->add_setting(): ‘option’: Settings API option (get_option()) ‘theme_mod’: Theme Mods API option (get_theme_mod()) Try changing this: $wp_customize->add_setting( $this_theme . ‘_theme_options[‘. $setting .’]’, array( ‘default’ => $param[‘default’], ‘sanitize_callback’ => … Read more

Use different single.php file based on condition

In a previous edit you used: if (in_category(’21’)) { include (TEMPLATEPATH . ‘/single-21.php’); } else { include (TEMPLATEPATH . ‘/single-29.php’); } This is part of your solution, but before I continue, some important notes: Don’t use include like that, instead get_template_part(‘single-21’); works better Indent correctly This clashes with how IDs work in the template heirarchy. … Read more

Turn get_posts as string into an array for use in theme admin options

This… array(’54’=>’Post #1′,’23’=>’Post #2′, ‘654’=>’Post #3′,) … is not a string. It is an array definition. All you need to do is create an array, which is what you want, and skip the string completely. function post_page_options(){ $post_page_options = get_posts(‘category=orderby=title&order=asc&numberposts=”); foreach( $post_page_options as $value ) : $str[$value->ID] = $value->post_title; endforeach; return $str; }

Problems to disable the comments for my statics pages

First of all, thanks to Ian Stewart for the codes here- In functions.php paste the following codes: // Template for comments and pingbacks. if ( ! function_exists( ‘my_comment’ ) ) : function my_comment( $comment, $args, $depth ) { $GLOBALS[‘comment’] = $comment; switch ( $comment->comment_type ) : case ‘pingback’ : case ‘trackback’ : // Display trackbacks … Read more