Make Custom Taxonomy Category Use Parent Template

Hook into template_include filter add_filter(‘template_include’, ‘research_term_template’); function research_term_template( $template ) { if ( is_tax(‘classifications’) ) { $parent = get_term_by(‘slug’, ‘oldresearch’, ‘classifications’); // to improve performance you can hardcoding ‘oldresearch’ term id // $parent = 12; if ( term_is_ancestor_of( $parent, get_queried_object(), ‘classifications’ ) ) return get_template_directory() . ‘/taxonomy-Classifications-oldresearch.php’; } return $template; }

How to output the taxonomy term name in a widget

Check the properties of get_queried_object(). Sample code: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Current Term Widget */ add_action( ‘widgets_init’, array ( ‘Current_Term_Widget’, ‘register’ ) ); class Current_Term_Widget extends WP_Widget { public function __construct() { parent::__construct( ‘current_term’, ‘Current Term’ ); } public function widget( $args, $instance ) { if ( isset ( … Read more

Change in custom taxonomy permalink causes 404 error for another custom taxonomy

After many efforts I have solved it, but it’s not completely what I want, as I had to compromise on one thing and passed some separators in the URL. Example: example.com/separator1/parentatx/childtax/separator2/postname/ In order to avoid 404 errors, in case of pagination and another custom taxonomy, I created some rewrite rules. Here is my code: First … Read more

How to display posts from a single category within a custom taxonomy

I believe your looking for something like this <?php $args = array( ‘posts_per_page’ => 1, ‘post_type’ => ‘inventory’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘inventory-category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘bulk-racks’ ) ) ) ); query_posts( $args ); while ( have_posts() ): the_post(); // do stuff here ?> <?php endwhile; ?> Heres how to … Read more

Adding session variable and/or cookie based on user-selected input

You can definitly use PHP session variables. Follow this blog post (“Listing 3”) for the best way to enable PHP sessions in WordPress. Namely, you need to use this code in your plugin or in your theme’s funtions.php: add_action( ‘init’, ‘session_start’, 0 ); After that you can use basic session variables to set the country … Read more

Custom taxonomy term as class?

You could do something like this <?php $terms = get_the_terms( $post->ID, ‘taxonomy_name’ ); ?> <div class=”myclass<?php foreach( $terms as $term ) echo ‘ ‘ . $term->slug; ?>”> <!– content –> </div> http://codex.wordpress.org/Function_Reference/get_the_terms