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?
- How do I exclude a custom taxonomy from the post loop
- Is ACF being a honey trap? [closed]
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- display posts with same taxonomy term
- Get value in custom field with taxonomy [closed]
- Remove Category description textarea
- Use custom posts as taxonomy term meta replacement?
- Custom metabox for menu administration page?
- Custom Fields and performance
- Custom taxonomy – custom sortable column
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- How to display submenus on page based on referring top-level parent?
- Automatically assign taxonomy term if custom meta value exists
- Modify main loop in taxonomy archive page
- how to search in custom fields & custom taxonomy for custom search
- Getting yoast title for custom taxonomy
- 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
- Solve product properties with custom taxonomies?
- All posts are still shown when adding category argument to query
- Is it acceptable to build functionality into a theme built for a client? [closed]
- Create a random unique 6 digit number as custom field for custom post type
- Custom fields to taxonomy
- Custom fields ‘for’ custom taxonomy?? Can someone explain why?
- How can marge these loop code?
- Print terms with taxonomy and metabox value
- How to Filter Posts by Custom Fields?
- Styling Taxonomy Terms Individually
- Limit the number of acf content when displaying in post loop [closed]
- What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
- I am trying to display information from a custom table from my wordpress users pages
- 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
- where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop
- 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
- Does using custom taxonomy is more CPU efficient than using meta_data?
- WordPress implode & wp_insert_post question
- how to store values in database at hierarchical view
- If Custom Taxonomy
- WP REST API – get custom taxonomies based on terms & filter
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- Loop to display ONLY custom taxonomy parent information [closed]
- Filter through custom taxonomy with an array of taxonomy IDs
- 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?
- How to add custom checkboxes from loop to WooCommerce product variation options?
- 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
- Create new Taxonomy, add extra fields, register terms AND extra fields values?
- Adding a Section for Visitors
- 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
- Output slugs to use as class names for every taxonomy a post is attached to
- Reset custom taxonomy meta data after saving
- List active taxonomy terms
- Get meta value when the page is a blog archive
- How to get name of custom taxonomy
- Avoiding stripping of HTML in Custom Taxonomy Meta Field
- add custom fields in custom taxonomy meta box in wordpress-3.5.2
- Update fields with post object and custom tax with wp_insert_post
- Use custom field as tag slug
- Advanced search form with filters for custom taxonomies and custom fields
- Taxonomy Extra Meta [duplicate]
- Loop custom post type by taxonomy (Category)
- Any way to make custom taxonomy field searchable?
- Advanced WordPress search form based on custom taxonomy and custom meta value
- Get custom taxonomy value of post and output posts in same taxonomy
- More than one Hierarchical Taxonomy and SEO
- How much worse is querying custom fields compared to custom taxonomies, quantitatively
- Loop posts without any taxonomy
- How to looping taxonomy terms?
- I want to show image from custom field image on my custom page template
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)