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 posts
Related Posts:
- change the default order of posts only for specific categories
- Query category-specific, paginated posts and allow viewer to change sort order
- How to modify this function to exclude also the post belonging to a specific category?
- Inject post (from specific category) between posts in Loop
- Build a content and excerpt grid loop with paging and options for # of posts
- Alter query on edit.php
- how to display active, upcoming and past event with featured listing with pagination
- Count number of published posts by type
- Get taxonomy terms only of the WP_Query current posts
- Exclude posts from homepage having a specified tag
- Hide post if matches current month and year
- Can’t search posts using WP_QUERY inside AJAX Function
- How can I use wp_query to show all product data using just the products ID?
- Displaying the last post on static homepage
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Sort query_posts for Parent Pages to menue order or the count?
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- How to store post ID’s in cookie or session to display the same posts later
- Sort by page information by Ascending Numbers
- Counting Search results, and displaying the offset per page
- How to get post ID in a Page?
- WP_Query: getting posts where custom field exists
- Array to string conversion on array_map
- Store metakey value as an array
- Increment paged on WP_Query
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Modify main query before it run without pre_get_post
- Do not duplicate posts with multiple categories in multiple loops
- array_rand not working correctly?
- WP_Query() load selected post
- Saving a post ID to use in a form elsewhere on website
- posts_nav_link pulling in multiple post types
- Remove Post if Advanced Custom Field is checked to fix paging
- Wp Query : Order by distance lat,lon
- search.php to search only the post title
- posts_per_page displays only 2 posts instead of 4 posts
- Is there anyway I can call the year once?
- Query on a repeater date (acf)
- Need to show 7 posts from actual date
- Check the database for a postmeta field
- Getting info about selected posts using one WP_Query
- How to display last whole post on the homepage
- Only Get A Certain Number of Posts From WP_Query
- Create a hierarchical loop at predefined markup requirements
- insert thumbnail image from php script
- Sort / Filter Queries
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Automatically create a loop for post ID
- Why does WP_Query show only the same post even with different categories and endwhile?
- Custom query_posts() parameter
- Posts sortable column not sorting properly for custom field numbers
- Does wp_query and query_posts affect website performance? [duplicate]
- Pagination in category.php not functioning
- /page/2/ redirect to 404
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- How do I exclude the current post from the upcoming post query
- Exclude first post from wp query
- How to make posts_like_dislike reference current post when iterating?
- Category Attachment Pagination 404 Error on 2nd Page
- Order posts using a custom array
- Looking for most performant way to execute several similar WP queries within shortcodes
- API response to be stored locally
- How to get 2 or multiple custom post types in wordpress functions.php
- “before delete post” action fire when the post is updated?
- Use wp_get_recent_posts with search term
- WP_Query loop, does not display special characters in title correctly
- Remove query string specific key value
- Displaying a button on each post
- Trying to make php run in a post
- Improving WP_Query for performance when random posts are ordered
- Get the last month with posts using a recursive function…
- Use WP_Query in shortcode
- Creating bulk posts with Youtube videos
- Order posts randomly, not by date
- have_posts() execution failure
- Accessing post->ID outside of the loop for listing child pages
- Sorting multiple custom post types without a meta key/value pair by sort order
- Remove posts after a given amount of time
- Working with query_posts ( arrays and query strings)
- Automatically add custom CSS to new posts using a category template
- How to filter posts by post format “standard” from wp-json api?
- Why is variable not working on custom sql query using wpdb?
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- How Display Posts on category
- Hide wordpress field if data is empty in post!
- How to query for pages/post depending on slug?
- Accessing post’s meta data based on user’s click of a post
- Query all posts of a custom taxonomy term
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Retrieving Author ID in wp-admin area
- Random order of WP_Query results with highest meta value
- Custom page archive query by url var calling page twice on one of my custom queries?
- WordPress custom slug (endpoint) and compare all links
- Reset Popular post query?
- Getting a specific post values to another div or modal
- How to query for posts with a null or blank post_name?
- WordPress pagination not working with search page
- get current custom post ID by WP_Query method
- Trying to add attribute to my posts’ featured image