Skip Navigation

[Resolved] View not showing correct information

This thread is resolved. Here is a description of the problem and solution.

Problem:

I have two Views displaying different custom fields of a case study. The first View (Hero) works correctly, but the second View (Credits) is displaying data from a different post instead of the current case study. The Views are configured the same way, so I don’t understand why one works and the other doesn’t.

Solution:

In the Template section of the Credits View, use the shortcode [types field='credits' item='$current_page'] to ensure the field pulls data from the current page instead of another post. This issue occurs because when a View is placed directly on a page, it does not automatically inherit the post context like it would in a post template. Generating the shortcode via the Fields and Views button ensures the correct attributes are included.

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.

This topic contains 0 replies, has 1 voice.

Last updated by Christopher Amirian 2 months, 2 weeks ago.

Assisted by: Christopher Amirian.

Author
Posts
#2795706
screen.jpg

Tell us what you are trying to do?
I am trying to show credits of a case study (custom field) via view in a page in which there is anoher view showing the hero of the case study (working correctly). The 2 are configured exactly the same way but for some reason the new one doesn't work. There is sorting limit at 1 to show just the view where the page is shown.

Is there any documentation that you are following? No

Is there a similar example that we can see?
This one is working: hidden link (hero)
The new one not working: hidden link (credits)

What is the link to your site?
hidden link (maintenance mode, can make an account)

#2795961

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. I wonder if you can create a completely new view and use the same option as the credits and see if it works individually.

If yes then please use that new view in conjunction with the one that is working and delete the one which is not working.

If the issue persists, I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

Please also give me the link to the view that you newly created as mentioned in the steps above.

#2796326

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Thank you for the login information. I create da test page and used the WORK - Credits view there.

I checked the view and the loop item just loads a template.

	<wpv-loop wrap="1" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-md-12">[wpv-post-body view_template="loop-item-in-sm-work-credits"]</div>
		</div>
		[wpv-item index=other]
			<div class="col-md-12">[wpv-post-body view_template="loop-item-in-sm-work-credits"]</div>
		[wpv-item index=pad]
			<div class="col-md-12"></div>
		[wpv-item index=pad-last]
			<div class="col-md-12"></div>
		</div>

It is completely different from the Hero view. So I am not sure what you want to achieve wit the Work credit view if you give me more information I will be happy to help.

#2796332

Hello Christopher,

I am not sure what you did but I believe it's not relevant to what I am having issue with.

If you go to this page: hidden link

At the bottom of the page there is a view that is called: SM - Work (credits)
hidden link

This view, within the works (wiredmark for instance, the one I linked) is not working. In that specific page it should show the custom field 'credits' but instead is showing 'credits' from a different post.

Thanks,
Matteo

#2796372

Christopher Amirian
Supporter

Languages: English (English )

Screenshot 2025-02-13 at 10.36.16 AM.png
Screenshot 2025-02-13 at 10.34.56 AM.png

Hi,

Thank you now I get what you mean. In the Template section of the view you need to add this shortcode:

[types field='credits' item='$current_page']

You can generate that shortcode by clicking the "Fields and Views" button, selecting the Credits and under "Post Selection" tab you need to choose "The page where this View is shown" option.

Please check the screenshot.

I did that and now the view shows the current credits content.

Thanks.

#2796396

Hi Christopher,

Thanks for the explanation and this is now great.

However I wanted to understand why do I have to specify it here this time and the other view is doing that automatically.
Also, I've always used views without using the '$current_page' value and it has always worked.

Is there something wrong with this view or with the website?

Thanks,
Matteo

#2796440

Christopher Amirian
Supporter

Languages: English (English )

Hi Matteo,

Nothing wrong is there, just if the view is used on a page you need to use that method and if it is used in a post template the default option will suffice.

Using the button and the dialog box to generate the shortcode will be the best option as it will generate all the necessary attributes.

Thanks.