Skip Navigation

[Resolved] Issues with displaying multiple post types in a view.

This support ticket is created 2 years, 10 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 1.65 hours from now. 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+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by mariaR 2 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#2270029
conditional block.png
Screenshot 2022-01-18 232345.png

Hi, I'm trying to display two different post types in a view.
The headings are showing up just fine but the images are only showing for one of the post types (see screen shot attached).

I have tried putting the image and heading in a conditional block as seen in screen shot attached.
This will work for about a day or two! Then I'll visit the page a day or two later and see that it isn't working even though I haven't changed anything!

I have tried the conditional block with a toolset container block inside(displaying the image as the background of the container) and with a toolset image block inside. Both work for a bit then cause the same issue.

What should I do to fix it so I can see images from both post types in the same view?

#2270309

Nigel
Supporter

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

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

If you have two post types—each with its own customf field group and image field—being output by the View then you would need separate image blocks for each.

You shouldn't really need to worry about conditional blocks, because if there is no source for an image block it will simply output nothing.

The tricky part may occur when inserting the image blocks and selecting the dynamic source.

You may find that you can only set up the source correctly if the first result of the View (which is where you design the View loop output) is the corresponding post type.

(When setting up dynamic sources, it expects that the current post used for the preview actually has some data for the selected dynamic source.)

So if the first result of the View is of post type A, you may have a problem adding an image block where the source should be an image field belonging to post type B.

If you do encounter such a problem you may want to set up the image block for post type A, save the page, then make some temporary change to the View such that the first result is of post type B, and then set up the corresponding image block. Then you can revert the View settings to what they should be.

#2270441

Thank you for your reply. I have tried many different combinations still with the same outcome.

How would I fix it?

#2270443

Also, how would you explain why it works for a day or two but then it stops displaying?

How do you tell it to bring up a specific post type like you were saying?

#2270505

Nigel
Supporter

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

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

If it works for some time then stops working there must be some change made on the site to account for it.

If it's okay with you I can check the back end myself to see if I make sure it is set up correctly?

Let me mark your next reply as private so that we can get log-in credentials from you—you may want to create a temporary admin user for us to use that you can later delete. And be sure to have a current backup of your site.

Can you also confirm the url of where we can see the problem.

#2271131

Nigel
Supporter

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

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

Thanks for the access.

I looked at your site and can see that it is standard posts for which the images are not being displayed.

And that is to be expected.

In the output of your View loop you have added one image field, and the source for the image field is the Main Featured Image of the Field Group for Product Reviews.

But the Field Group for Product Reviews belongs only to the product review post type, not standard posts, so there is no image from that source to show for posts.

So you need to add two image blocks, one where the source is the field group for product reviews, and another where the source is the field group for posts.

To avoid the possibility that two images could be output, you would put the image blocks inside a conditional block, where the conditions are to test what is the current post type, and display the post image when the post type is post, and the product review image when the post type is product review.

I've done that on your site, and it is working, and I would only expect it to stop working if you save any changes to the page.

(By the way, I did notice one confusing thing that I am going to report, which is when you have multiple post types in a View the dynamic source will insist you choose the "Current Product Review" as a source, for example, even though it could be any of the post types being shown by the View. It works for any post type, but the labelling is confusing, and I'll see if we can get that changed.)

#2273543

Cool! Thanks for fixing it. Looks like it is working fine now.