• Resolved polymo

    (@polymo)


    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 to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Thank you for contacting us.

    Since you are using our Pro features on your website, you’ll need to open a support ticket at my.elementor.com.

    www.remarpro.com rules state that commercial products are not supported here.

    Kind regards,
    David

    Thread Starter polymo

    (@polymo)

    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

    Hello @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 “[email protected]”.

    We will be glad to assist with anything related to our products all the time.

    Regards,
    Said

    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.