Skip Navigation

[Resolved] How to pass attribute to view’s PHP API

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

Problem:
How to pass attribute to view's PHP API'
Solution:
You can simply add attribute to view's PHP API using array.

For example:

$args = array( 'wpvprchildof'=> $atts['wpvprchildof'], 'ids'=> $atts['ids']);

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/to-be-continue-get-number-of-results-for-view-filtered-by-shortcode-attribute/#post-642252

Relevant Documentation:

This support ticket is created 6 years, 7 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 2 replies, has 2 voices.

Last updated by vimalS 6 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#642049
Screenshot_12.png

Topic to be continue : https://toolset.com/forums/topic/get-no-of-results-returned-by-view-in-template-after-all-filters-have-applied/

I have one more filter with this, which is Exclude posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]. what I need to add in above code you gave?

#642252

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

You just need to change the arguments you pass to your view as given under:

 $args = array( 'wpvprchildof'=> $atts['wpvprchildof'], 'ids'=> $atts['ids']);

And call the shortcode as:

[wpv-students-count wpvprchildof='[wpv-post-id]'  ids="12,13,14"][/wpv-students-count]

Where:
Pass the required IDs to "ids" attribute.

#642749

Thanks
I have changed $args array as well

 $atts = shortcode_atts( [
      'wpvprchildof' => 0,
      'ids' => 0
    ], $atts );