The main query is generated before the template is loaded, the results of the main query are how WordPress knows what template to load. If you want to alter query parameters of the main query to change things like orderby
, you should add a function hooked to pre_get_posts
.
The argument passed to the function contains the query parameters of each query, so you can check which query it is and only alter your taxonomy main query. This function would go in your theme’s functions.php
file, or a plugin.
function wpd_adhesion_taxonomy_queries( $query ) {
if ( !is_admin() && $query->is_tax( 'adhesion' ) && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'wpd_adhesion_taxonomy_queries' );
Related Posts:
- Retrieve taxonomy terms in order of their post’s date?
- Order wordpress taxonomy parent terms by their children count
- Ordering Taxonomies / Changing term_id
- Problem with orderby
- line order number start numbering from second line (SOLVED)
- Order custom taxonomy hierarchy
- Order taxonomy terms by the frequency of use in the last 30 days
- Can One Taxonomies Terms be Ordered by A Seperate Taxonomy?
- How to orderby Taxonomy Term in a WP Query
- How to show a hierarchical terms list?
- The Difference Between Hierarchical and Non-Hierarchical Taxonomies?
- How to perform unit testing on proposed patches in Trac?
- Attaching taxonomy data to post with wp_insert_post
- Need a simple but complete example of adding metabox to taxonomy
- How to get taxonomy term of the current page and populate queries in the template
- Can the default “post tags” taxonomy be renamed?
- Custom columns for taxonomy list table
- Custom Taxonomy WP_Query for All Terms in a Taxonomy?
- Custom taxonomy list page?
- How to add a default item to a custom taxonomy?
- Remove the category/taxonomy description field?
- Add ‘Description’ to taxonomy ‘Quick Edit’
- Why does get_term() require taxonomy? Are term_ids not unique?
- How does Woocommerce store variation attributes, and how can they be retrieved per-variation? [closed]
- tax_query in get_posts() not working?
- Different post sort order within different categories
- What is wp_insert_term “alias_of” arg for?
- Automatically Assign Parent Terms When A Child Term is Selected
- get term by id without taxonomy
- How to organize and cache additional data associated with terms?
- Using pre_get_posts to set posts per page, how do I?
- get a specific taxonomy term name
- wp_set_object_terms() Fails to Set Terms
- wp_set_object_terms() — prevent overwrite?
- Taxonomy terms sort by… Last name!
- List Hierarchical Term List with Count with Related Term
- Is there a way to set singular/plural labels for taxonomy term names?
- WordPress – Creating multiple versions of the same single-customtype.php depending on selected taxonomy categories
- Better way to enforce category hierarchy in post_categories_metabox?
- get_terms() How many is TOO many?
- Exclude custom taxonomy from search results and archive pages
- Child Terms not Displaying on the Taxonomy Term Admin Screen
- get_terms with posts that have a different taxonomy with term x
- How to display child term of current term’s parent taxonomy?
- List all taxonomy terms / Show links if posts are attached, else names
- List taxonomy terms as links
- check if tag exists in wp database
- Sorting custom taxonomy causes menus error
- How to overwrite a specific parameter in a core taxonomy?
- Order Posts by Taxonomy and Meta Value
- Set a cookie in WordPress, using a select form and Jquery
- How to add terms to taxonomy with wp_insert_terms?
- How to update taxonomy custom field with wp_update_term()?
- Get_term_by only returns one item from array
- How to set a Preset category for custom post types?
- Can we have same term slug in different taxonomies?
- Is there any difference between post in child term and child & parent terms?
- Add additional data to a specific taxonomy term when used in a post
- Set default (auto) slug prefix for Tags
- How to have “the most used tags” taxonomy always expanded?
- Add Thumbnail to wp_list_categories()
- Get parent and first child taxonomy terms?
- How to add automatically keyword to taxonomies when a post published, and assign them to the post
- Display the number of published posts for each custom taxonomy term?
- Display Custom Taxonomy in Sidebar in Two Columns
- Get wordpress taxonomy archive and sort by year
- Search for tags
- Create and move terms for taxonomies
- Display Post by taxonomy and taxonomy child
- Display Post by taxonomy and taxonomy child if exist
- Fatal error: Call to undefined method stdClass::filter() in wp-includes\taxonomy.php on line 805
- WP native tag suggest metabox. How does it process tag id?
- Missing term_id and term_taxonomy_id when adding a term using wp_insert_term() function
- How to always display a specific post from the search result first
- Update all posts at once
- Change order of WordPress tag cloud
- How to get the last term from taxonomy?
- Count posts for each taxonomy term for each month
- Custom taxonomy archive – No posts found [closed]
- Display parent taxonomy name and list child taxonomies below it?
- List post from current taxonomy children
- What hooks/filters are there to alter selected terms on post save?
- Count argument in get_terms has no effect on ouput/doesn’t work
- Filter blog archive by category in URL
- How can I remove links from the function “get term list”?
- Get Term names from WP Term Object
- tax_query: What to pass when I want to have all terms?
- Custom Roll/Custom Post Type – Can’t Select Categories
- Let users create a new custom taxonomy entry from frontend (without creating a post)
- Get the term for an taxonomy archive when the term has no posts
- Trying to list terms of a custom taxonomy using get_categories
- Add a term to an attachment submitted from front end
- orphaned taxonomy terms remove by sql query
- functions to create term and child terms
- Get and loop posts with all taxonomy terms
- Unable to delete a Category and Tag that share same slug
- base directories / URL
- Get current custom user taxonomy
- Conditional tag affecting taxonomy term and its children?
- WordPress REST get all items without a taxonomy assigned