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
- How do I exclude a custom taxonomy from the post loop
- Is ACF being a honey trap? [closed]
- Add custom taxonomy fields when creating a new taxonomy
- Display category posts grouped by taxonomy
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?
- display posts with same taxonomy term
- Get value in custom field with taxonomy [closed]
- Including all terms in wordpress tax_query
- Display one post from each term in a custom taxonomy [closed]
- How much faster is a tax query than a meta query?
- Remove Category description textarea
- Use custom posts as taxonomy term meta replacement?
- Custom metabox for menu administration page?
- Custom Fields and performance
- register_rest_field for custom taxonomy fields that are assosiated with custom post type
- Custom taxonomy – custom sortable column
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Group posts that matches a term in a loop
- Custom taxonomy template loop
- How to display submenus on page based on referring top-level parent?
- List Custom Taxonomy Values according to a Post Meta Value
- How get custom field from custom taxonomy?
- Automatically assign taxonomy term if custom meta value exists
- How to handle “the_terms” inside loop
- Modify main loop in taxonomy archive page
- How to add custom field to custom taxonomy in 4.4
- 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
- Single reusable value for post meta: Custom Taxonomy or Post Meta?
- 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]
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- Operations with custom fields values in a loop
- echo current taxonomy id for this loop?
- How do I Use Multiple Loops with WP_Query?
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- $wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?
- 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
- Meta Key Value in current-user-only loop
- How to Filter Posts by Custom Fields?
- Styling Taxonomy Terms Individually
- Can I use a Custom Meta Value inside of ‘get_the_terms’?
- Posts in loop displaying all taxonomies
- How to add contents of a custom field to a taxonomy term list?
- How can I hide admin columns showing extra custom taxonomy fields?
- Conditional display for custom fields/taxonomy
- How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?
- Limit the number of acf content when displaying in post loop [closed]
- Register custom taxonomy from a Advenced custom field option page
- Avoiding stripping of HTML in Custom Taxonomy Meta Field
- Order by custom field attribute
- Trying to achieve row posts below category with multiple loops in custom tax
- 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
- Custom Taxonomy + JQuery Tabs
- WordPress show posts from children terms of a taxonomy term
- Advanced search form with filters for custom taxonomies and custom fields
- Transfer taxonomy to custom field
- Custom Fields link to other pages, not search
- 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
- Order by a meta field in query loop
- How much worse is querying custom fields compared to custom taxonomies, quantitatively
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- Loop posts without any taxonomy
- How to looping taxonomy terms?
- How to show to show post list under the specific category name using jetengine query?
- 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)
- How to handle custom taxonomy archive when no posts will have that taxonomy
- How can I list all the meta in a custom taxonomy?
- ACF – How to get custom taxonomy term image field
- Grouping posts by 2 different taxonomies