2

This doesn't work:

add_rewrite_rule('^spor/?','index.php?pagename=search&search_text=spor',top);

It goes to the search page but search_text=spor is not taking effect. (Like Empty)

When I manually browse from browser:

www.mydomain.com/index.php?pagename=search&search_text=spor

the query works succesfully. What am I missing?

1 Answer 1

2

Custom query vars have to be added via the query_vars filter to be parsed within rules.

function wpd_add_query_vars( $qvars ) {
  $qvars[] = 'search_text';
  return $qvars;
}
add_filter( 'query_vars', 'wpd_add_query_vars' );

You can then get the value with get_query_var('search_text').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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