WordPress does not recognize $_GET post filters
-
Hello
I have to implement filters for the list of posts in every template page, so I embedded the code below as described in this article only to get a blank page upon clicking the submit button:
<form class="post-filters"> <select name="orderby"> <?php $orderby_options = array( 'post_date' => 'Order By Date', 'post_title' => 'Order By Title', 'rand' => 'Random Order' ); foreach($orderby_options as $value => $label): echo '<option '.selected($_GET['orderby'], $value).' value="'.$value.'">'.$label.'</option>'; endforeach; ?> </select> <input type="submit" value="Filter"> </form>
The article says ‘WordPress already knows what the order and orderby parameters mean and it uses them in the default query’, but apparently WP doesn’t and shows the following in the web address bar with no markup in the page (where ‘test’ is the name of the root directory):
https://localhost:8888/test/?orderby=post_title
Please someone tell me if WordPress can parse $_GET variables and if possible direct me to a tutorial which explains how post filters can be implemented without resorting to the use of a plugin?
Thank you in advance.
- The topic ‘WordPress does not recognize $_GET post filters’ is closed to new replies.