Change taxonomy of posts

If you are not sure how your site will behave when upgrading or changing themes, you should create yourself a test/dev site. There are many tutorials out there that can help you set up a local test site. You can make a copy of your live site and transfer that all to your test site … Read more

Display the first tag assigned to a post

Assign taxonomy terms (ie tags) to a post in a specific order has no sense form me unless the taxonomy is hierarchical. The core tags taxonomy is no-hierarchical and category is hierarchical. So, you can define a hierarchical custom taxonomy or use the built-in category taxonomy. Think in a natural flow of description terms. In … Read more

Query Posts with Custom Taxonomy from a Custom Post Type

It looks like you forgot to set the field parameter to search for slugs: $args = array( ‘post_type’ => ‘advertisement’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘group’, ‘terms’ => array( ‘homepage’ ), ‘field’ => ‘slug’, ) ) ); Notice that the taxonomy query uses the term_id as the default search field. I would also use … Read more

Displaying custom post types with taxonomy

Follow these steps . Add the following code to your functions.php add_shortcode( ‘list-team’, ‘list_team_members’ ); function list_team_members( $atts ) { ob_start(); // define attributes and their defaults extract( shortcode_atts( array ( ‘type’ => ‘post’, ‘posts’ => 5, ‘category’ => ”, ), $atts ) ); // define query parameters based on attributes $options = array( ‘post_type’ … Read more

rewriting for custom taxonomy rewrite

All you need is pass the URL structure in the arguments when registering your custom taxonomy. For example: add_action( ‘init’, ‘register_my_taxonomy’ ); function register_my_taxonomy() { $args = array( //Complete the arguments for your taxonomy // The rewrite argument should looks like this ‘rewrite’ = array( “slug” => “cars/my-tax” ) ); register_taxonomy( ‘my-tax’, ‘my-post-type’, $args ); … Read more