• Resolved swcomm

    (@swcomm)


    I’m using is_category to sort an archive by a custom field – works great. This category has subcats that I want to sort the same way, but the subcat archive sort reverts back to post date. How do I make the conditional revert to the parent cat conditional when a subcat archive is diplaying? Everything I’ve tried either gives me all posts in the parent cat, sorted correctly or gives me the subcats without the sort. Using:

    if( is_category('32') ) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    'meta_key' => 'lastname',
    'orderby' => 'meta_value',
    'order' => 'asc',
    'cat' => 32,
    'paged' => $paged
    );
    query_posts($args);
    }

    I can get it to work if I change the cat id to the subcat id, but that means I’ll have to have over 20 subcat templates, which I don’t want. Using an array of the subcat ids simply gives me the entire parent category. Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter swcomm

    (@swcomm)

    Issue is resolved. For those with a similar issue, I ended up using a category template with the sort I wanted, and added a theme function that forces the subcats to use the parent cat template: Subcat template

Viewing 1 replies (of 1 total)

The topic ‘Sort subcategory archive by custom field’ is closed to new replies.