Skip Navigation

[Resolved] View is not retrieving data from a field

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 3 replies, has 2 voices.

Last updated by peterv-6 7 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#474354

I have added a new field against one of my post-types but I am having troubles displaying the content in a parent Post

The other fields in the CPT are displayed in a Parent Post by a series of views inserted into a content template for the parent CPT.

I copied the approach I had taken for the other fields from creation of the field duplicating a view used successfully for another field and inserting the view into the parent CPT.

I successfully imported data which is stored in the correct field for the post type Yet I cannot get the data from the child post type to appear in the parent post.

Could you perhaps have a look at my site and see if you can figure out what I have done wrong?

Kind regards

Peter

#474419

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Peter

Yes, sure, I can't really advise anything without taking a look directly.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes.

Can you confirm which post types and custom fields we are talking about.

#474618

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screen Shot 2017-01-06 at 15.22.55.png
Screen Shot 2017-01-06 at 15.17.42.png

Hi Peter

I took a look and can see what the problem is.

Look at the screenshot.

I edited the loop output sections of the views you use to output the ranks to add a line which shows the post id and title of the current item in the loop from which the ranking custom field data is being taken.

You'll see that it is the same in each of the 3 ranking sections.

That's not surprising because the View is identical in each case apart from the types field added to the loop output section.

The problem is that you are creating ranking posts to store the custom field data. See the second screenshot which shows the ranking posts for Shark Shield. You have a bunch of them.

Whether by luck of judgement your views which you use to display the ranking data for Shark Shield are set to retrieve the most recent ranking post (for which Shark Shield is the parent). The post from 22 December 2016 is currently the most recent post, so your ranking data for the first two views appear correctly on the front end, because that 22 Dec ranking post has the custom fields for wa-rank and wa-best-ever-rank populated.

Looking at the publication dates, before you published the 22 Dec ranking post there would have been a time when the 2016 annual rank post was the most recent, and that doesn't have entries for the wa-rank and wa-best-ever-rank custom fields, so they would have been missing on the front end.

Anyway, your new view for wa-annual-rank-2016 doesn't output anything because it is trying to output the value of the custom field wa-annual-rank-2016 which is set on the 2016 annual rank post but the post returned by the view is the most recent ranking post, i.e. the 22 Dec ranking post, which doesn't have the field set.

You need a way to filter the ranking posts so that it doesn't just come up with the most recent ranking post for which Shark Shield is the parent, but gets your annual ranking post.

You have two options, I think. One is to make a new post type for the annual ranking posts and filter by that.

Or you could add a taxonomy to the annual ranking posts to distinguish them and add a second filter for that.

By the way, as the views for current-rank and best-rank are identical aside from the field you output, you might want to amalgamate them to save yourself an additional query.

#475021

Nigel

Doh!! thanks for looking at this for me... I found an alternate and easier solution to the issue.. ordering posts by the relevant field rather than by setting up a separate custom post or adding a taxonomy to the post.

Have incorporated 2 other views into 1 as you suggested.

Thanks so much.

Cheers

Peter

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