Skip Navigation

[Résolu] How to pass attribute to view’s PHP API

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 6 années et 7 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Marqué : ,

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par vimalS Il y a 6 années et 7 mois.

Assisté par: Minesh.

Auteur
Publications
#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

Les langues: Anglais (English )

Fuseau horaire: 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 );