Skip Navigation

[Closed] Need secondary sorting based on custom field

This support ticket is created 4 years, 3 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 29 replies, has 2 voices.

Last updated by Shane 4 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1735429

Actually this code seems to break other views in the site - causing them to return no results.

#1736347

Any chance I might accomplish this same thing by nesting views? The title is from the parent post and I would like to group the curricula (children) under one heading for the district anyway.

#1737603

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dung,

Sorry for the delayed response.

This might be possible, however is the year field on the child post ? We can sort the parent view by the post title and that will work, however if the child view doesn't have the year custom field then we won't be able to sort it by the year.

If it does have the year field on the child post then you can definitely achieve this with a nested view listing.

Thanks,
Shane

#1737633

Yes, the year is on the child and so are the grades (which is what the client now wants for secondary sorting).
The other factor is that I'm using a search and maps. I was only able to get the map working with the search on the parent (because it has the address associated). Are these the correct steps to set this up with nested views?
Search and results on the parent post (with address) - return posts sorted by post tile alpha ASC. Then nest a view of all child posts filtered by post-relationship (current post in loop) and sorted by grade-level ASC in the loop of the parent search? Does the child posts view go in the loop wizard area or the loop item area?

#1737699

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dung,

Given that you only want to search by the Parent field parameters then yes this is the correct step.

Does the child posts view go in the loop wizard area or the loop item area?

If there is a content template on the view then you can add it to the content template for that view. If there isn't then you will add it to the loop area inside the wpv-loop tags.

Thanks,
Shane

#1738051

I created the two views but there are 2 issues: the parent name in the main view is repeating instead of only listing the district 1 time and the children are listed under every parent rather than just the ones they belong to. hidden link. I'd like e.g. 21st Century to only be listed 1 time with only it's children showing under it.

#1739559

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dung,

Would you mind allowing me to have access to the site to check the view for you?

Secondly with the repeated titles for 21st Century I see that they are 3 different posts with 21st Century in its name so each will show as a different entity.

I've enabled the private fields for your next response.

Thanks,
Shane

#1739861

Please do note edit any of the other views.
Sorry - I was still working on the view when you looked at it -- 21st Century used in the title of the "district" children> "curriculum" posts just to keep track of them. What I would like is for the parent district, e.g., 21st Century Prep School to only show one time as a link with all (3) of it's children (curricula) listed underneath in the search results. You can see the children that should show on this district detail page: hidden link

#1739915

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-08-14 at 3.29.15 PM.png

Hi Dung,

I found the issue. The Parent filter should've been set to get the parent information from the view that it was inserted in. See Screenshot

Secondly your Parent view is listing our Curriculum when it should be listing out district.
hidden link

The relationship is between District and Curriculum so the parent view must be listing out the District for it to work correctly.

Thanks,
Shane

#1739933

I don't see a change to the results. Districts are still listing multiple times with all children shown every instance of the district. If I change the main view to display districts then I can't filter on district post titles and all the other filters on the curriculum also break.

#1742319

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dung,

The problem is that you are using 2 child views. I'm under the impression that you want to filter your view by the Parent Post Title which would be the District.

However your Parent and Child view are both listing out Curriculum, the only difference is that your Parent view now is retrieving the Parent's post title through the child, This means you are adding the following shortcode.
[wpv-post-title item='@parent.district']

Your current filters are then currently incorrect since its not filtering the Parent information.

Thanks,
Shane

#1745529

If I switch to making the search and results on the district there doesn't seem to be any way to have filter on the post title (district post title) - am I missing something?

#1745615

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dung,

We have to solve the issues in order. Currently i've created a small test view to see if the Post relationship filter works and from the link below you can see that it is now filtering for the correct posts.
hidden link

The next step i'm assuming is that you want the child post view to be sorted by the year field, this i've done.

I also see where one of your posts in the Relationship with "Abbotsford" doesn't have the year filled out. This will cause the post not to show up.

What you can do is to go ahead and use my test view to continue building out your system while checking each modification that you made so that you can know when an issue comes up.

Looking forward to hearing from you soon.

Thanks,
Shane

#1758599

I haven't had a chance to look at this project again. I'll be back in touch soon.

#1760523

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dung,

Thanks. Once you have an update please let me know.

Thanks,
Shane

The topic ‘[Closed] Need secondary sorting based on custom field’ is closed to new replies.