0

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!

1

You are looking for get_query_var() function:

$orderby = get_query_var('orderby');
  • ah - this nearly works but returns 'wp_posts.post_date DESC'. – v3nt May 5 '11 at 14:55
0

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.

  • that also gets 'wp_posts.post_date DESC' instead of just 'date'. The original isn't in the var_dump either. – v3nt 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
0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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