• I have a hierarchical custom taxonomy named children and inside the taxonomy i have two children “easton” and “kiari” the code calls all posts from the taxonomy, but they are still sorted independently so i get all posts sorted by post date for easton, and then all posts sorted by post date for kiari. The question is how do i combine the taxonomy and sort by post date so i get posts sorted by date regardless of weather its from easton, or kiari.

    Current sort example:
    easton july 30 2011
    easton july 15 2011
    easton july 1 2011
    kiari july 30 2011
    kiari july 14 2011
    kiari july 2 2011

    Desired Sort Example
    easton july 30 2011
    kiari july 29 2011
    easton july 15 2011
    kiari july 14 2011
    kiari july 2 2011
    easton july 1 2011

    here’s my code:

    <?php
    
    // List posts by the terms for a custom taxonomy of any post type
    $tax = 'children';
    $tax_terms = get_terms( $tax );
    if ($tax_terms) {
    	foreach ($tax_terms  as $tax_term) {
    	$args = array(
    
    		"$tax" => $tax_term->slug,
    		'post_type' => 'post',
    		'post_status' => 'publish',
    		'posts_per_page' => -1,
    		'caller_get_posts'=> 1,
        	'orderby' => 'post_date',
        	'order' => 'DESC',
    
    	);
    
    		$my_query = null;
    		$my_query = new WP_Query($args);
    
    		if( $my_query->have_posts() ) : ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Perhaps have another category called ‘Children’ (or a custom taxonomy item if that’s necessary)? Make sure all the posts about both children are in the category ‘Children’ and then use that category list.

    Does that work?

    Cheers

    PAE

    Thread Starter jhonsvick

    (@jhonsvick)

    I’m not sure what you mean Peredur. right now i have a hierarchical custom taxonomy (works like a category) called children. so i’m querying all post in the entire taxonomy. both of which have subsets or children categories named easton, and kiari. the problem that i’m getting is combining them first and then sorting them and displaying them. I’m definately not a php guy, i struggle through what i do know, so any help here is greatly appreciated.

    Did you ever get this figured out, jhonsvick? I’m dealing with something similar.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Sort hierarchical Custom Taxonomy’ is closed to new replies.