Skip Navigation

[Resolved] View is not showing results when called from View API and filter by shortcode

This support ticket is created 3 years, 11 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 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 9 replies, has 2 voices.

Last updated by Sotiris Krontiris 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2157287

I am trying to call a specific view from the View API to show the records of some CPT. The ids of the records are passed as an attribute on the view shortcode

Link to a page where the issue can be seen: hidden link

I expected to see: on the bottom right side bar some results.

Instead, I got: A view that returns no results.

#2158445

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and share details how exactly you are trying to pass the IDs.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2159269

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When I check the page without login: hidden link

On top right box I see "No records" found and on top right bottom box I see a only white box.

Do I require to login as any specific user as I do not see what you shared with the reference screenshot you shared.

Can you please be bit more specific what thing you expected to display and whats wrong , may be you can share few more screenshots.

#2159449
Expected_view.jpg
Current_view.jpg

You will see that there are no records shown in the view named "seamen-you-know-suggestion".
I have tried to enter an id of a Custom Post Type directly in the view filter section from admin, but again no lack
The "expected_view" screenshot is from the development environment that the view has the expected behavior.

Please log in with the below user.
Username: sotiriskrontiris
Password: 9EK)Hnu7DP^ipMPVcT^%YR5M

#2159473

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I open the PHP page template file at page-seaman-home.php but I do not see the code you shared in that file.

echo render_view(['name' => $defatts['template'], 'seamenids' => $ids]);

Where you added the above code?

#2159561

Inside the PHP page template file at page-seaman-home.php the below code

echo do_shortcode( "[seamanSuggestJoiners template='seamen-you-know-suggestion']" ); 

calls the shortcode seamanSuggestJoiners which is defined in the file toolset-customizations\vsl_seaman_shortcodes.php which has the code

echo render_view(['name' => $defatts['template'], 'seamenids' => $ids]);
#2159739

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I can see that it generates the following query:

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.ID IN (114040,114319,113515,91476,92410,112540,114033,114036,114037,111518,113337,58964,58842,58926,59222,113944,59493,113988,97733,114953,61138,111364,58544,58677,62193,114371,114256,114411,114437,112546,114603,112883,113962,59817,60296,107122,113165,62393,57921,91170,59750,114027,98700,104877,113145,113243,113454,111998) AND wp_posts.post_author IN (248)  AND wp_posts.post_type = 'seaman' AND ((wp_posts.post_status = 'publish'))  ORDER BY wp_posts.post_date DESC LIMIT 0, 4

Can you please run this query and check if it returns any result on your database server?

#2159917

The generated query is wrong. The specific condition

AND wp_posts.post_author IN (248) 

should not be in the WHERE section. In the view configuration there is no filter for the post_author

#2161705

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm not sure as you have added the custom code you will have to dig a bit to know from where the post_author is hooked in.

#2161973

My issue is resolved now. Thank you!