Skip Navigation

[Resolved] sorting child post with a parent post post field

This support ticket is created 7 years, 9 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.

Our next available supporter will start replying to tickets in about 2.41 hours from now. Thank you for your understanding.

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)

This topic contains 18 replies, has 2 voices.

Last updated by Shane 7 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#417279

I am trying to: I have a post type called authors, another one called publications and another one called publication-authors witch is children of authors and publications. Actualy in the authors content template I have a view displaying the publications of each author (publication author) and I want to sort these publications with a publications post field called publishing date

I visited this URL:

I expected to see:

Instead, I got:

#417375

Shane
Supporter

Languages: English (English )

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

Hi Juan,

Thank you for contacting our support forum.

Our Views plugin actually has an order feature. What you need to do is go to your view and edit it.

Next is scroll to the Ordering section and then select your custom field that you want to sort by.

This should allow you to sort the view by Published Date.

Please let me know if this helps.

Thanks,
Shane

#417500

I have already done that but it doesn't work. The fact is that Publising date is a custom field that belong to one of the parents and doesn't concur with the post date.
I have a filter that filters publications by "Select posts that are children of the Post where this View is shown". But if I change that I can't display publications that belong to one author.
I have to filter the author-publication by author and then sort them by the custom field "Publishing date" of the parent post type "publications"

#417637

Shane
Supporter

Languages: English (English )

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

Hi Juan,

It seems I need a visual example to understand the setup correctly.

But from what I gather, the view that you want to sort does not have the publishing date custom field correct?

This is because you mentioned that the custom post type being displayed by the view actually has the published date on the parent post.

The view can only sort by custom fields on the current posts that it displays. Why not move the published date custom field to the child instead of having it on the parent?

If it remains on the parent then we are not able to sort it by this field.

Thanks,
Shane

#419656

Yes you are correct.
Is there any way I can copy the custom field of the parent in the child automatically? I mean, I have a lot of publications and a lot of authors. Could I copy the custom field "publishing date" (of the parent publications) to the children (publication-authors) and get the values that it has?

#419702

Shane
Supporter

Languages: English (English )

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

Hi Juan,

Unfortunately not.

The only way i can see you sorting the child posts and this doesn't meant that they will that they will be in order of the time each child post was created.

This means that they will be in order of which the Parent is displayed.

What you can do is to create a view in a view setup and have the parent view display the child view. This way you can sort the parent view by published date and the child posts will display based on the order you set the view to display the published date.

For more information and a tutorial on how to set this up, you can just go to the link below.
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

Please let me know if this helps.
Thanks,
Shane

#421800
publicationsView2.png
publicationsView.png
pruebaView2.png
pruebaView.png
contentTemplate.png

I have been trying and it doesn't work. I have created a view that displays the publications by the publishig date(called prueba), then I have displayed this view in another view that displays publication-author, called publications (child of publications and author). The view called publications has a query filter "Select posts that are children of the Post where this View is shown" because it is inside of a content template of authors. this way I can display only the publications that belongs to one author but I cant sort them with the view prueba, it doesnt work. I attach images of the code.

#421926

Shane
Supporter

Languages: English (English )

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

Hi Juan,

Would you mind providing me admin access to the site so I can assist better?

I'll enable the private fields for your next response.

Thanks,
Shane

#422990

Shane
Supporter

Languages: English (English )

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

Hi Juan,

Thank you for the credentials but they don't seem to work 🙁

Would you mind checking on them and let me know when I can log in 🙂

Thanks,
Shane

#423438

ok now it works, sorry for the mistake

#423508

Shane
Supporter

Languages: English (English )

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

Hi Juan,

Thanks for updating the credentials for me.

I managed to take a look at the issue.

Could you have a look and let me know if everything is ok ?

Thanks,
Shane

#423675
fallo.png

Is not, this year's publications dont appear and all of them are duplicated

#423874

Shane
Supporter

Languages: English (English )

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

Hi Juan,

The reason why the duplications are occurring is because of this code below.

<div class="p_title"><a href='[wpv-post-url id="$publications"]'>[types field="rich-text-title" id="$publications" raw="true"][/types]</a>,[wpv-post-body view_template="Auxiliar - publishing media name" id="$publications"], [types field="publishing-year" output="raw" id="$publications"][/types], [types field="media-index" output="raw" id="$publications"][/types] </div><div style="clear:both"></div></li>       

Specifically here

[types field="rich-text-title" id="$publications" raw="true"][/types]

Because of that line there are duplications because you are displaying the post title of another post type. So if multiple posts from Publication authors have the same parent then it is going to show the same title multiple times.

Thanks,
Shane

#426601

and how can I avoid this??

#426782

Shane
Supporter

Languages: English (English )

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

Hi Juan,

The only way to avoid this is to not let your view display the publication author parent information.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.