Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

say i've got a url http://bfami.modernactivity.co.uk/category/museum/orderby/date/order/desc/

that works with;

add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(/page/?([0-9]{1,}))?/?$', 'index.php?category_name=$matches[1]&paged=$matches[5]&orderby=$matches[2]&order=$matches[3]', 'top' );

how do i get the value of orderby or order on a page? Think wordpress removes the GET values which is what i'd normally use...

Just want to highlight the active order filter on the page!

share|improve this question
add comment

3 Answers

You are looking for get_query_var() function:

$orderby = get_query_var('orderby');
share|improve this answer
    
ah - this nearly works but returns 'wp_posts.post_date DESC'. –  daniel Crabbe May 5 '11 at 14:55
add comment

think its: $wp_query->query_vars['orderby'].

You can dump all the query string variables by var_dump($wp_query->query_vars); It should be in there.

share|improve this answer
    
that also gets 'wp_posts.post_date DESC' instead of just 'date'. The original isn't in the var_dump either. –  daniel Crabbe May 6 '11 at 8:56
    
did you add orderby to the list of possible query vars with add_filter( 'query_vars','my_insert_query_vars' );? –  Patriek May 6 '11 at 11:01
add comment
up vote 0 down vote accepted

ended up with;

class="<?=( strpos(  $oby ,'date' ) ? 'active' : null )?>"

though can imagine i'll need to get this working on one job or the other...

thanks all!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.