get a list of posts from Custom Taxonomy

Check out the Taxonomy Parameters. <?php $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘taxonomy_name’, ‘field’ => ‘id’, ‘terms’ => ’22’ ) ) ); $the_query = new WP_Query( $args ); while ( $the_query->have_posts() ) : $the_query->the_post(); //content endwhile; ?>

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

Disable single pages and archives and keep preview

You can redirect, when someone tries to see the archive or the single of your custom post type, just redirect them to another page, just put this in your functions.php add_action( ‘template_redirect’, ‘theme_redirects’, 99 ); function theme_redirects() { if ( is_post_type_archive( ‘post_type_slug’ ) || is_singular( ‘post_type_slug’ ) ) { wp_redirect( ‘my_url’ ); die(); } } … 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

How to show multiple post types on taxonomy archive?

As you point out, if you want separate loops for different post types you’ll need to use a separate WP_Query() for post type. In the template you can get the current term (ID) being viewed via: get_queried_object_id() (see source) $args = array( ‘post_type’ => ‘staff’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘themes’, ‘terms’ => get_queried_object_id(), … Read more