Yes,
You can call action “pre_get_posts”.
add_action('pre_get_posts','search_filter');
You can add parameter :
$args = array(
'post_status' => 'publish',
'posts_per_page' => 6,
'paged' => $paged,
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
You can use above parameter e.g. :
function search_filter($query){
if ( !is_admin() && $query->is_main_query() ) {
$query->set('post_status', 'publish');
$query->set('meta_key', 'event_date');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'ASC');
}
}
Related Posts:
- Is it possible to sort the post based on a custom field?
- How to separate posts in loop?
- Loop through custom taxanomy in post and display custom fields from posts
- Convert post meta to custom taxonomy?
- Count tags for current post and save into custom meta field (and update it on post edit)
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- sort Posts by custom user filed
- How can I show custom field according to taxonomy?
- How do I create a term for every value of a post meta?
- Advanced search form with filters for custom taxonomies and custom fields
- Display category posts grouped by taxonomy
- display posts with same taxonomy term
- Get value in custom field with taxonomy [closed]
- Display one post from each term in a custom taxonomy [closed]
- Remove Category description textarea
- Custom metabox for menu administration page?
- Custom Fields and performance
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Automatically assign taxonomy term if custom meta value exists
- How to handle “the_terms” inside loop
- how to search in custom fields & custom taxonomy for custom search
- Outputting an array of term meta values in a custom WooCommerce tab?
- Storing data into custom taxonomies VS post custom fields (post meta)
- get_the_terms() to show all custom taxonomies
- List the number of posts for each custom taxonomy and specific custom field value
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- Custom fields to taxonomy
- Custom fields ‘for’ custom taxonomy?? Can someone explain why?
- How can marge these loop code?
- How do I display a list of posts under all hierarchical children of the current taxonomy?
- Print terms with taxonomy and metabox value
- How to Filter Posts by Custom Fields?
- Styling Taxonomy Terms Individually
- How can I hide admin columns showing extra custom taxonomy fields?
- Is it possible to store Json data in post_meta and manipulate
- Save custom taxonomy data in different table not in wp_options for my own plugin
- Add Custom Taxonomy for Blog Meta Info
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- How to create a dependent drop-down and options in dropdown must be manageable from admin panel
- Search Tool only refreshes Page without showing results
- where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop
- Default Custom Field Value Automatically Update
- Display value of custom field of custom taxonomy in single post?
- Creating terms vs custom post meta to save data?
- Removing “s” from search with custom parameters
- Multi-select field for Taxonomy can’t save the value
- Display all posts that use a custom taxonomy
- Can I access a post meta field before the loop?
- how to store values in database at hierarchical view
- WP REST API – get custom taxonomies based on terms & filter
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Exclude taxonomy term from all loops, but having it on widget
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- saving meta/custom field to tag
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Loop to display ONLY custom taxonomy parent information [closed]
- Filter through custom taxonomy with an array of taxonomy IDs
- What’s the best way to add taxonomy’s image in 2017?
- Count of posts by different parameters?
- WooCommerce custom taxonomy as meta?
- SQL / wp_update_post: change post custom field to CPT post taxonomy
- Only display latest custom taxonomy post
- Filter by Custom Taxonomy AND Custom Field
- Can You Build Page Templates Without Extra Files
- How to get the term description in a taxonomy term archive query?
- Chaining Taxonomy Queries
- Extra Meta Data for WordPress Multisite Taxonomy
- Problem with sorting in custom child taxonomy archive page
- Is there a way to nest taxonomies or custom fields deeper than one level below the post type?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- How to use custom slug and custom templates for custom taxonomy?
- Create multiple taxonomies with custom fields values on the fly when creating new posts
- display ACF repater field in archive page
- Group posts in a category based on tags in custom taxonomy
- How to loop custom posts that have an exact match in taxonomy terms?
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Create new Taxonomy, add extra fields, register terms AND extra fields values?
- Dropdown (with onChange) with custom taxonomies
- ACF Custom field not showing in Timber Taxonomy page
- Pre_get_post custom taxonomy combined with custom fields?
- Adding a checkbox field to a (custom) taxonomy
- Add and Custom category for posts “PAGE”
- how to filter the data’s comparison operators (>= &
- How to filter a taxonomy meta field to the ‘single_term_title’ filter hook
- Custom post type term names with ampersand in the term name
- Query pages by child term
- Where to put a migration script to switch post information?
- Avoiding stripping of HTML in Custom Taxonomy Meta Field
- add custom fields in custom taxonomy meta box in wordpress-3.5.2
- Use custom field as tag slug
- Custom Taxonomy + JQuery Tabs
- Transfer taxonomy to custom field
- Custom Fields link to other pages, not search
- Get custom taxonomy value of post and output posts in same taxonomy
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- How to show to show post list under the specific category name using jetengine query?