Check Views results

To check if a View returns any results at all or count the results (amount of posts) of the View, you can use the function get_view_query_results()

An example

$filtered_posts = get_view_query_results( 21 );//change to ID of first View 
$all_out = count($filtered_posts);

Example Threads:

https://wp-types.com/forums/topic/conditional-output-with-found-count-or-items-count

https://toolset.com/forums/topic/view-filter-and-sorting/


Let us know if this snippet is not working for you:

This snippet doesn’t work
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments