Skip Navigation

[Closed] Views do not seem to be displaying the right content

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

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

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

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Caridad 9 years, 9 months ago.

Assigned support staff: Caridad.

Author
Posts
#177421

This seems may be sort of the same issue I'm having - and reported on - over here: https://toolset.com/forums/topic/using-publication-month-as-reference-point-for-filter-in-views/

So it may be either a case that this can't be done the way I am hoping to be able to do it or I am missing something / doing something wrong.

Anyway...

I want to be able to use a single custom post type that I created for monthly real estate market updates using data from two different real estate boards.

One board offers less data than the other, so the Content Template needs, somehow, to refect this.

One board offers information on 6 different metrics, while the other board only offers information on 3 metrics.

Currently I have two content templates - one for each board, to allow me to display different summaries of the metrics each board provides (this prevents empty fields showing up on the posts with less data).

It occurred to me that this is not the most efficient way of tackling the issue, so I created a View for each board that includes tables for the data.

The problem I've run into is that the View seems to be using the most recent month's data as the reference point for every post, regardless of when it was published.

So November uses November's data (which, of course it should), October uses November's data, September uses November's data, and so on.

The View's content selection is set to the appropriate Custom Post Type, ordered by post date, query options (don't include current page) are deselected, limit is set to display 1 and offset is set to none, and the query filter is set to "Select posts with taxonomy: Market Update Cities the same as the current page."

I've opened up the Custom Post Types and clicked on the update button but they're still display the data from the most recent month, not the month of the actual post.

Please advise.

Many thanks,

Dawson

#177860

Dear Dawson,

It seems like you are using a View where you should be using a Content Template. Could this be the case?

A View is meant to be used to show a list of all records (or a subset by using filters).
Content Templates are for displaying the data associated to a single post, which is what you need.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#178009

Hi Caridad

Thanks for the clarification on this (saved me hours of frustration).

I think I've been able to get the result I was after by being a little creative.

I was in a situation where I basically needed to select from between 4 different Content Templates for a custom post type I'd created.

The reason for this is that there are some fundamental differences in the amount of information from one CPT to the next and I didn't want to have empty tables and such showing up so I created 4 different Content Templates.

But, I really wanted this to happen more or less automatically, which was why I thought that a View was the way to go.

Anyway, it looks like I've gotten the result I wanted by approaching it a little differently.

I've created 4 new content templates and have named them for a custom field that essentially helps to differentiate them.

I copied and pasted all of the content from the old Content Templates and pasted them into the new ones.

Then I created another new content template and added a Content Template to it and used the name of the custom field in the slug.

[wpv-post-body view_template="[types field="custom-field-slug-here" output="raw"][/types]-updates"]

Now I've got the CPT set to the new Content template and it's all working.

I did something similar with a View that I inserted into a Content Template (using custom fields in the View name that were taken from the CPT) and it worked so I figured I'd give it a try for this.

Do you foresee any possible problems with this approach?

Cheers

Dawson

#178191

Dear Barber,

That will work with no problems. Combining shortcodes is very powerful. You can also check the custom field is there with wpv-if:

[wpv-if field="wpcf-custom-field-slug" evaluate="!empty($field)"]
[wpv-post-body view_template="[types field="custom-field-slug-here" output="raw"][/types]-updates"]
[wpv-if]

https://toolset.com/documentation/views-shortcodes/#vf-153493

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

The topic ‘[Closed] Views do not seem to be displaying the right content’ is closed to new replies.