Unless I’m missing something, I would think you could just use an OR (||) operator to check if it is_tag()
or is_tax()
:
add_action( 'pre_get_posts', 'sort_conference_by_date' );
function sort_conference_by_date( $query ) {
if ( $query->is_main_query() && !is_admin() ) {
if ( $query->is_tag() || $query->is_tax() ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'start_date');
$query->set('order', 'DESC');
}
}
}
Related Posts:
- Using get_terms for custom taxonomy in functions.php
- wp_get_post_terms() returns WP_Error in functions.php but in template it works
- Adding a class to tag list in a function
- Make Categories a Dropdown Menu in Media Library
- Identical custom taxonomy slugs for same hierarchical children
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- Get list of all custom tanonomy id
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- Output a specific link in WordPress post if the single post’s category’s name contain certain word
- Suggest Users basing on User taxonomy
- How add body_class from wp_termmeta
- Display ACF category image on archive and single template files
- Get URLs for AJAX Filter Checkboxes WordPress
- Using get_terms for custom taxonomy in functions.php
- I’m getting invalid taxonomy in init action
- Taxonomy On Index Page
- Only seems to be displaying one child when there are supposed to be multiple
- Excluding iPad from wp_is_mobile
- paginate_links() don’t properly work in search.php?
- How to influence the information displayed on widget inside wp-admin
- How can I get $id variable in widget’s form function?
- difference between add_object_page and add_menu_page
- How to hook into the quick edit action?
- Make WordPress size and name images for Retina.js
- How to programmatically set a menu to be the Primary Menu?
- Pinterest Integration Using functions.php
- Adding WooCommerce to a Custom Theme – not working [closed]
- Changing itemprop from logo to image on custom logo?
- Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
- how to edit functions.php in a child theme
- Only display link to author social media when it exists [closed]
- Get current page_id before loop, in functions.php
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- Change Rating range in Link Manager
- Create single.php for specific tag by tag id or name
- function to erase swear words
- str_replace function in theme
- Function call via ajax – can’t figure it out?
- Using $themename Variables
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- WordPress Menuing Question :focus
- How to auto refresh when user change postcode
- Add sequential number to a Gravityforms form
- wp-comment author- url +, email filter hook
- What WordPress function to use to get meta value by using meta keys?
- how can I just add to parent theme function(s) instead of redeclaring whole the function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- How to create an onclick event on an image in a post?
- Why does re-using this function not work? [closed]
- using jQuery on only one page
- Setting a default text for excerpts of a particular category
- How can I use Woocommerce $product->get_attribute in functions.php? (if at all)
- Possible to hook into Media Library preview File column and use a custom image?
- Warning: preg_match(): No ending delimiter ‘^’ found in
- How to Add Shortcode to html img code?
- Logout Redirect and also WP-login.php Redirect
- Proper Way to Load stylesheet on Condition
- How do I place a function in a standalone page?
- Problem in using Customizer
- Ajax resetting my global variable
- Conditional custom menu?
- What function actually renders the wp_admin_bar ? How can I call it?
- Do I Need to Prefix Variables Inside Functions?
- How to change the author box selection on a post to a custom taxonomy
- Detect Ajax call inside pre_get_posts function
- Render page with specific id from functions.php
- Display Child Pages if no child Exists Display Siblings
- How to show ACF value under post/page title in wp-admin
- What is wp_get_post_tags for media tags?
- Filter works on last selection but no others
- Undefined variable issue for wp_get_attachment_image_url
- ACF Flexible in TCPDF
- get_current_user_id() always return 0 in if else statement
- How do i tweak my wp Post title base on category of the post
- Why isn’t comment validation working?
- I’m creating a online store for my website, my aim is to add description to products in home page only how can i achieve it?
- Menu and category highlighting for a single post
- “Conditional query tags do not work before the query is run. Before > then, they always return false. “
- Change ‘Categories’ to ‘Topics’
- I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js
- True email confirmation for registration (keeping unvalidated users from user table)
- Code I am placing in the wp_footer is going outside the entire HTML frame!
- How to use if (is_page_template (”))
- wordpress function through ajax not being called
- How to assign results to variables?
- Restoring pages in wordpress
- Different body image backgrounds on different pages, posts and categories
- Hide certain post types from editors
- Language switcher for subdomains
- Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
- How to mirror exactly the left admin menu on front end?
- Add Function For Instances of Custom Text in Multiple Category IDs to display in post content
- How to add a class name to the ancestor of a post?
- Make a table out of meta box
- is_user_logged_in() isn’t working
- Retrive post by tags PHP code
- Add custom css to theme
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- Add functionality to block comment authors in the Comment edit pag
- WordPress enque the same script causes the setInterval not to work