Skip Navigation

[Resolved] Query results for more than one view with get_view_query_results

This support ticket is created 4 years, 1 month 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 1 reply, has 1 voice.

Last updated by Suzanne Wenger 4 years, 1 month ago.

Author
Posts
#1563955

I am trying to pull the results of two different views using get_view_query_results():

$results = get_view_query_results( 28195 );
$amount = count($results);
$results-r = get_view_query_results( 34157 );
$amount-r = count($results-r);

if ($amount >= 1 || $amount-r) {
    if ($amount >= 1 ) {
        $args = array('title' => 'Home Page Events Listing');
        echo render_view( $args );
    }
    if ($amount-r >= 1 ) { 
        $args-r = array('title' => 'Recurring Events Listing');
        echo render_view( $args-r );
    }
} else { ...

The code above is not working, can the get_view_query_results( ) function only be used once?

Thanks for your help,
Suzanne

#1563997

Sorry, after posting my code I realized my error...a simple syntax issue...

$results = get_view_query_results( 28195 );
$amount = count($results);
$results_r = get_view_query_results( 34157 );
$amount_r = count($results_r);
 
if ($amount >= 1 || $amount_r >=1) {
    if ($amount >= 1 ) {
        $args = array('title' => 'Home Page Events Listing');
        echo render_view( $args );
    }
    if ($amount_r >= 1 ) { 
        $args_r = array('title' => 'Recurring Events Listing');
        echo render_view( $args_r );
    }
} else { ...

You can't use a "-" when declaring a variable. I replaced the dashes with underscores "_".

Sorry to bother,
Suzanne

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.