Title: Posts Widget: Current query, order by title
Last modified: January 22, 2021

---

# Posts Widget: Current query, order by title

 *  Resolved [polymo](https://wordpress.org/support/users/polymo/)
 * (@polymo)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/posts-widget-current-query-order-by-title/)
 * I’m creating a glossary of terms on a website, and using a custom post type (
   Glossary) and custom taxonomy (Letters). I need the posts in these archives to
   be ordered by title, instead of by date.
 * On the archive template I’m using a posts widget with ‘current query’. By default
   the posts are ordered by date and there is no option to change the order (all
   options are removed with Current Query).
 * So I’ve set up a custom query to order the posts by title, instead of by date.
   However, I cannot seem to get it work.
 * My code is:
 *     ```
       add_action( 'elementor/query/pre_get_posts', function ( $query ) {
       if ( ! is_admin() && $query->is_archive() && $query->is_main_query() ) {
       if ( get_query_var( 'post_type' ) == 'glossary' ) {
       $query->set( 'category_name', 'letter' );
       $query->set( 'posts_per_page', -1 );
       $query->set( 'order', 'ASC' );
       $query->set( 'orderby', 'title' );
       };
       };
       } );
       ```
   
 * Can anyone help? Is there a bug with my code, or is there a bug with the Elementor
   posts widget?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fposts-widget-current-query-order-by-title%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [davidl](https://wordpress.org/support/users/davidlbc/)
 * (@davidlbc)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/posts-widget-current-query-order-by-title/#post-13960131)
 * Hi,
 * Thank you for contacting us.
 * .
 * .
 * Kind regards,
    David
 *  Thread Starter [polymo](https://wordpress.org/support/users/polymo/)
 * (@polymo)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/posts-widget-current-query-order-by-title/#post-13960481)
 * Hi David,
 * Thanks for your reply. I had already contacted Elementor support, and received
   this reply:
 * > We would love to help you out with this, but I am afraid we can’t provide support
   > for development/custom code issues as this is beyond the scope of support we
   > provide here. Here we can only provide support for existing features of Elementor
   > and its issues.
 * I was also recommended to post this on the Elementor Github forums but they also
   don’t provide support, only bug reports and feature requests.
 * I’ve also posted this on Stack Overflow and received a reply to correct my code,
   but it is still not working (the code in my original post above is the corrected
   version). So I don’t know if what I’m dealing with is a bug in Elementor or a
   problem with my custom query.
 * And all this because I want to order the posts by title instead of by date. A
   very simple thing that has become incredibly complicated.
 * I’m at a loss as to what to do now… Any help would be appreciated.
 * Kind regards
    Jordan
 *  [saidaboukhadra](https://wordpress.org/support/users/saidaboukhadra/)
 * (@saidaboukhadra)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/posts-widget-current-query-order-by-title/#post-13978500)
 * Hello [@polymo](https://wordpress.org/support/users/polymo/),
 * Thank you for replying.
    Unfortunately, as we don’t have control over custom 
   code we can’t provide feedback on your code structure, we can provide full support
   on what we provide related to Elementor on this forum and related to Elementor
   Pro via “support@elementor.com”.
 * We will be glad to assist with anything related to our products all the time.
 * Regards,
    Said
 *  [satraptech](https://wordpress.org/support/users/satraptech/)
 * (@satraptech)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/posts-widget-current-query-order-by-title/#post-14575882)
 * I don’t understand why the current query doesn’t have any sorting options in 
   the first place.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Posts Widget: Current query, order by title’ is closed to new replies.

 * ![](https://ps.w.org/elementor/assets/icon-256x256.gif?rev=3444228)
 * [Elementor Website Builder - more than just a page builder](https://wordpress.org/plugins/elementor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elementor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elementor/)
 * [Active Topics](https://wordpress.org/support/plugin/elementor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elementor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elementor/reviews/)

## Tags

 * [custom-query](https://wordpress.org/support/topic-tag/custom-query/)
 * [order by title](https://wordpress.org/support/topic-tag/order-by-title/)

 * 4 replies
 * 4 participants
 * Last reply from: [satraptech](https://wordpress.org/support/users/satraptech/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/posts-widget-current-query-order-by-title/#post-14575882)
 * Status: resolved