Default taxonomy template in plugin, override in theme

This is what I ended up using (for all those interested): function override_tax_template($template){ // is a specific custom taxonomy being shown? $taxonomy_array = array(‘tax1′,’tax2’); foreach ($taxonomy_array as $taxonomy_single) { if ( is_tax($taxonomy_single) ) { if(file_exists(trailingslashit(get_stylesheet_directory()) . ‘tax-template-directory/taxonomy-‘.$taxonomy_single.’.php’)) { $template = trailingslashit(get_stylesheet_directory()) . ‘tax-template-directory/taxonomy-‘.$taxonomy_single.’.php’; } else { $template = BASE_PLUGIN_DIR . ‘includes/tax-template-directory/taxonomy-‘.$taxonomy_single.’.php’; } break; } } … Read more

Custom post types with categories in template

<?php $args = array( ‘post_type’ => ‘cars’ ); // How can I add a category-filter to this? $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘Car-Types’, ‘field’ => ‘slug’, ‘terms’ => ‘Audi’ ) ) ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); echo ‘<li>’; the_title(‘<h3>’, ‘</h3>’); the_content(); echo ‘</li>’; … Read more

How do I define a lookup table that will work across all PHP elements of the template?

Loading it in the header should work, or on the init hook. You will need to declare it global as well. So… // define global $trans_home; $trans_home = array(‘en’ => ‘Home’,’it’ => ‘Home’,’de’ => ‘Home’,’zh’ => ‘首页’,’es’ => ‘Página de inicio’,’fr’ => ‘Page d\’accueil’); // and use in your templates global $trans_home; echo $trans_home[qtrans_getLanguage()];

Creating Sections for Post Types

Set your regular permalinks to /blog/%postname%/ Register your custom post type with has_archive => TRUE and with_front => FALSE. Example: add_action ( ‘init’, ‘register_project_cpt’ ); function register_project_cpt() { register_post_type( ‘projects’, array ( ‘has_archive’ => TRUE, ‘hierarchical’ => TRUE, ‘public’ => TRUE, ‘publicly_queryable’ => TRUE, ‘rewrite’ => array ( ‘slug’ => _x( ‘projects’, ‘slug’, ‘text_domain’ ), … Read more

Use a separate template for the home page only

I assume that template-blog-full-width.php is a page template and that you’d like to use this page template as the template to be used on the homepage. What you can do is to create a copy of the template-blog-full-width.php template and name the copy front-page.php. That’s about it. WordPress will always use front-page.php template when on … 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

implement separate templates for 1 post type

You may use template redirect action to check if there is parameter set for description and based on that you can show desired template. <?php add_action(‘template_redirect’, ‘course_template_redirect’, 1); function course_template_redirect() { global $wp_query; if($wp_query->post_type==’courses’ and $_REQUEST[‘showdesc’]==’1′) { //include your template from your theme folder. for e.g include(‘mytheme/coursetemplate.php’); } } ?>