Skip Navigation

[Resolved] I need to ordering view by profile type and secondary sorting by post title

This support ticket is created 6 years, 2 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 2 voices.

Last updated by Christian Cox 6 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1106653

I am trying to:

I need to ordering view by profile type (works ok) and secondary sorting by post title (not working).

The first filter works ok but the second filter by post title alphabetical order is not working

Link to a page where the issue can be seen:

hidden link

I expected to see:

Instead, I got:

#1106654
Edit View  — WordPress.png

find a printscreen attached with my view backend configuration

#1106812

It looks like it's working correctly except for the first item: Leopoldo E. Garcia Mansilla. Please try the following troubleshooting steps:
- Copy the code from this View's Loop editor and paste it here for me to review.
- Temporarily deactivate all plugins except Types and Views. Activate a default theme like Twenty Seventeen, then test again.
- If the problem is resolved, reactivate your theme and plugins one by one until the problem returns.
- If the problem was not resolved, please take a screenshot of the post editor screen in wp-admin so I can see Leopoldo's profile post.

#1110856

Christian, thanks for your help!

it was an error from a profile label. Now the order of profiles is working as I expected.

Now my code list all the profiles and order by profile type and then by A-Z post title.

This is great but i need to solve one special case where the order of the profiles is by profile type but also instead of ordering for A-Z post title, take the order of profiles from a menu that lists the profiles manually.

Hope to find a solutions, thanks in advance.

#1111644
Screen Shot 2018-09-19 at 12.15.49 PM.png
Screen Shot 2018-09-19 at 12.16.15 PM.png
Screen Shot 2018-09-19 at 12.16.25 PM.png

This is great but i need to solve one special case where the order of the profiles is by profile type but also instead of ordering for A-Z post title, take the order of profiles from a menu that lists the profiles manually.
Views doesn't offer a sorting option based on the order of a specific WordPress menu, unfortunately. That would require complex custom code that falls outside the scope of support we provide here in the forums.

You can sort by menu order, but this is the order applied in the Post Attributes meta box of the post type editor (see the screenshots), not the order of a specific menu. If you want to use this option, edit the post type and turn on the "Page Attributes" section. Then you can apply a "menu order" value in the post editor screen and use "menu order" in the View's secondary sorting option.

#1111821

Great Christian! thanks for your advice.

I follow the instructions and it works. Then i´ve found that this type of second sorting will be used for all the cases.

I need to apply this order to only 4 lawyers using page atribute for one specific view of a practice area.

I think that i need some extra code that detects url slug (eg: administrative-law)

and then run this special code to show the lawyers in a particular order at this practice area.

If not the usual second sorting A-Z will execute normally.

Hoping to find a solution, thanks in advance.

#1112276

The easiest way to do that is to create two Views and use conditional HTML to display one or the other.
- Revert the change in this View, then create a duplicate of this View. You can create a duplicate by going to Toolset > Views and hover over the View name.
- In the duplicate View, reapply the changes we discussed above.
- Use conditional HTML to display one of the Views based on the page slug or any other criteria you want to use. For example:

[wpv-conditional if="(ARRAY('page-slug-1','page-slug-2','page-slug-3') eq '[wpv-post-slug]')"]
  [wpv-view name="special-case-view-slug"]
[/wpv-conditional]<br />
[wpv-conditional if="(ARRAY('page-slug-1','page-slug-2','page-slug-3') eq '[wpv-post-slug]')" evaluate="false"]
  [wpv-view name="original-view-slug"]
[/wpv-conditional]

Replace page-slug-1, page-slug-2, page-slug-3 with the actual slugs of the posts that should include the special case View. Replace the View shortcodes to display the correct Views.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/