Skip Navigation

[Resolved] adding a view block to a content template, returns with an empty view loop

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

Problem:

How to migrate my website from development site to production website?

Solution:

You can follow our document to migrate your website:

Relevant Documentation:

https://toolset.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/

This support ticket is created 3 years, 4 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by brendaT-2 3 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#2286293
Screen Shot 2022-02-08 at 10.15.03 am.png

Tell us what you are trying to do?
When I add the view block, my view loop is empty and says:
"There were no posts found to display for this View's query"
I don't get the orange block where I can add elements to the block, that block repeats for each post.
This template is going to be a section on a page that contains one random Directory Listing post - to advertise/highlight a new listing in the directory.
So I want to add a grid of results that selects Directory Listing posts, randomises the returned posts, and has a limit of 1 post.
I have done this on my staging site and it works beautifully.

Steps:
On my PROD site, I:
I create a new content template, using block editor.
I give it a name "Directory New Advertising"
I select "View With" DL McMahons..." post (a Directory Listing post)
I add the view block
I select new view
do not select paging or search - it is purely a results block
I select grid
I select Directory Listing posts
and it creates the view, and inserts the view block into my template.
However the view loop is empty. I don't have the orange boardered box where I can add elements to the loop. It is like the template is NOT pointing to Directory Listing posts. On the view screen (admin menu-> toolset-> views) I have the following view created:
Directory New Advertising — Block Editor All post types ordered by post date, descending, 10 items per page with manual pagination.
It definitely doesn't say (eg from an events view) Events ordered by post date, descending, 10 items per page with manual pagination
I also cant save the template - the publish box is not active. it is blue with a greyed out "publish" on it. I can only save as draft.
Any help greatly appreciated. I have been stuck for 2 days and cant create this loop in the template.

I have uninstalled, downloaded and reinstalled the plugs (types, block and forms). no change.

What is the link to your site?
hidden link

#2286431

I didn't get an email notification about posting my question...I hope the log a problem facility is working OK.

#2286593

Hello,

The problem you mentioned above is abnormal, please check these:
Check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

If there are errors in your website, please try to locate the problem plugin/theme by these:
deactivate all other plugins, and switch to WordPress default theme 2021, and test again

#2287253

Back again... I couldn't enable logging - I tried but site went unavailable so I am not confident doing anything like that again.
I however have looked at all settings and plug ins between staging site & prod site. They both line up equal now.
I still get the error on prod. I have looked at the console in the browser and it seems to be complaining about the user - It gives a /wp-json/wp/v2/users?context=view&who=authors&per_page=50&_fields=id%2Cname&_locale=user:1 Failed to load resource: the server responded with a status of 403 (). See uploaded image.
I also uploaded console of working staging site - no error about user there. Can you help me?
the steps I performed to create teh console were:
add new template, name it.
add view -> new view -> no paging, grid -> directory listing content - create.

#2287255
Prod-user-error.png
Staging-no-error.png

images attached

#2287281

I am hunting through the problems/questions reported on your site by other users and I found...https://toolset.com/forums/topic/403-forbidden-screen/
Now, some background info...previously when I first added the post type "Directory Listings", I added all the custom fields I wanted, then I tried to create the single.php but I had no Directory Listing post with sample with data in it to show in the template I was creating. So I manually created a Directory Listing post,(add new directory listing post) but the data was incomplete for my purposes, so I went back and created a form to create the data. Et, voila! good data - so back to creating the template and I created the single.php for Directory Listings successfully. All good. Next step was to create a search and results template. Problems. no view loop. So I took the following steps:
==> refreshed code by uninstalling and reinstalling toolset types, blocks and forms, thinking the code might be corrupt, but problems still persisted.
==> deleted Directory Listing custom fields and Directory Listing post type - thinking it might be a data problem. I re-created post type, and all custom fields. Now when I select a field source (eg to sort posts on) on a template it is a pain because I can see 2xfields. eg "Dir Directory Listing type", and "Dir Directory Listing type x" (I had to add an x to the end of the current fields to distinguish them from the original fields - the slug remains even if you delete the field). It is real messy!! but anyway that is some background which sort of seems similar to the above problem reported. I would love to remove all the old slugs if possible (pls!). I will open another support question to ask this..

#2287335

I assume the same site works in your staging website, but does not work in your production website.

It should be a server/compatibility issue, it seems that your production website can not handle WordPress REST API requests
https://developer.wordpress.org/rest-api/
You need to check it with your production website server provider.

And in order to avoid other broken files/data issues, I suggest you try to follow our document to migrate your website from staging website to the production website:
https://toolset.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/

#2289945

My issue is resolved now. Thank you!