WordPress sorting posts by date and title using a dropdown
Here I put orderby attributes as option values – date and title. <form method=”GET”> <select name=”orderby” id=”orderby”> <option value=”date”>Newest to Oldest</option> <option value=”title”>Alphabetical</option> <button type=”submit”>Apply</button> <form> On the same page you can recieve select value and set as orderby attribute $wpb_all_query = new WP_Query(array( ‘post_type’=>’post’, ‘posts_per_page’=>-1, ‘order’=>’ASC’, ‘orderby’=> esc_attr($_GET[‘orderby’]) ); Use your loop to show … Read more