AI Verified

Name

Order archive posts by name

About

By default the Elementor archive posts widget does not have a query setting so using this snippet orders the archive content by name.

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Run snippet everywhere.

Codevault

davidmarek

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: Not Specified

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

14/11/2022

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Order archive posts by name

 
                    
1function order_archive_posts( $query ) {
2 // exit out if it's the admin or it isn't the main query
3 if ( is_admin() || ! $query->is_main_query() ) {
4 return;
5 }
6 // order category archives by title in ascending order
7 if ( is_post_type_archive() ) {
8 $query->set( 'order' , 'asc' );
9 $query->set( 'orderby', 'title');
10 return;
11 }
12}
13add_action( 'pre_get_posts', 'order_archive_posts', 1 );

0

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

0

Redirect user role on specific page

Added: 1 year ago

Last Updated: 1 year ago

This code will redirect a specific page based on the user role NOT being met.

WordPress Admin

AI Verified

0

Remove jQuery Migrate

Added: 1 year ago

Last Updated: 1 year ago

Remove jQuery Migrate

WordPress Admin

AI Verified

0

Hiding "Show Toolbar when viewing site" checkbox on profile page for specific user roles

Added: 1 year ago

Last Updated: 1 year ago

Have a user role that you want to hide "Show Toolbar when viewing site" checkbox on the profile page? This will remove the checkbox on specific user roles so Admins can control who has the admin toolb...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WordPress Admin

AI Verified

0

Order archive posts by name

Added: 2 years ago

Last Updated: 1 year ago

By default the Elementor archive posts widget does not have a query setting so using this snippet orders the archive content by name.