Skip Navigation

[Resolved] Category archive not displaying correctly; block cannot be previewed

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by jesseH-3 3 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1891015
error.jpg

Issue 1: I noticed that the category archive on my site is not sorting in the correct order. It used to work and I'm not sure when this happened.
Example of a category archive that isn't sorting correctly: /team-group/lighting-control-shades/ (see WP access info for full site URL)

Issue 2: In an attempt to investigate this, I went to edit the category archive and I get an error "This block has encountered an error and cannot be previewed." See attached screengrab.
To edit the category archive: /wp-admin/post.php?post=6363&action=edit (see WP access info for full site URL)

#1891025

Forgot to mention: the category archive should be sorting by custom menu order. I can't tell what it's sorting by currently... maybe by post date?

#1891493

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Issue 2: In an attempt to investigate this, I went to edit the category archive and I get an error "This block has encountered an error and cannot be previewed." See attached screengrab.
To edit the category archive: /wp-admin/post.php?post=6363&action=edit (see WP access info for full site URL)
==>
I've fixed that.

Issue 1: I noticed that the category archive on my site is not sorting in the correct order. It used to work and I'm not sure when this happened.
Example of a category archive that isn't sorting correctly: /team-group/lighting-control-shades/ (see WP access info for full site URL)
==>
I checked with my local test install and created taxonomy archive using blocks mode and set the order to Menu Order and its working as expected.

Then, I checked on your install and it seems that order of your archive is hijacked by your theme or any of third-party plugin you are using. So, as a workaround, I've added the following hook: pre_get_posts to 'Custom Code' section offered by Toolset:
=> hidden link

add_action( 'pre_get_posts', 'func_sort_tax_archive_menu_order',999);
function func_sort_tax_archive_menu_order($query) {
    if ( !is_admin() && $query->is_main_query() and $query->is_tax('team-group') ) {
     	$query->set('orderby', 'menu_order');        
    }
    return $query;
}

More info:
=> https://developer.wordpress.org/reference/hooks/pre_get_posts/

I can see now the archive does display the posts and respects the menu order. Can you please confirm it works as expected now.

#1891753

Thanks for your help. The only problem is that the posts are appearing in Descending menu_order instead of Ascending. Can you please change, or tell me how to change, to Ascending order?

#1892019

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

i've adjusted the code added to "Custom Code" section as given under:
=> => hidden link

add_action( 'pre_get_posts', 'func_sort_tax_archive_menu_order',999);
function func_sort_tax_archive_menu_order($query) {
    if ( !is_admin() && $query->is_main_query() and $query->is_tax('team-group') ) {
     	$query->set('orderby', 'menu_order');   
        $query->set('order', 'ASC');        
    }
    return $query;
}

I can see now posts are displayed in DESC order. Can you please confirm it works as expected.

#1894221

Thank you, the order is correct. My issue is resolved now.

#1894407

I'm sorry, I just noticed that this issue is also affecting my other category archive as well.
Example: /line-card/commercial-industrial/
The rows should appear in ascending order by post title. I'm not sure what order is being shown currently.
Can you help? The login info provided should still work.
Thanks!

New threads created by Minesh and linked to this one are listed below:

https://toolset.com/forums/topic/split-taxonomy-archive-sorting-not-working/

#1894689

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've split the ticket with your new question and I will follow up there.
=> https://toolset.com/forums/topic/split-taxonomy-archive-sorting-not-working/

You are welcome to mark resolve this ticket and we will continue with the above split ticket.

#1895511

Okay, will continue second conversation in the split topic. Thanks!