Skip Navigation

[Resolved] wpv-conditional with shortcode

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

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Shane 6 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#872261

I Have created this shortcode:

//Shortcode para devolver el número de 'Contrataciones-1' hijas de 'universidad-popular'.
function jm_numero_contrataciones_user_universidad () {
$universidad_ID = get_the_ID(); // Coge el ID del cpt universidad-popular
//Código cogido de Post Relationships API de Toolset. Cuenta los cpt contrataciones-1 que pertenecen al cpt universidad
$query = new WP_Query(
array(
'post_type' => 'contrataciones-1',
'meta_query' => array(
array(
'key' => '_wpcf_belongs_universidad-popular_id',
'value' => $universidad_ID
)
),

)
);
$posts = $query->posts;
$counter = count($posts);
return $counter;
// -- FIN -- Código cogido de Post Relationships API de Toolset. Cuenta los cpt contrataciones-1 que pertenecen al cpt grupo
}
add_shortcode ('numero_contrataciones_user_universidad', 'jm_numero_contrataciones_user_universidad');

-------------------------------

I use this [numero_contrataciones_user_universidad] and return 2. That´s ok.

But when I use this in a wpv-conditional I can see:

Case 1:

Numero contrataciones universidad: [numero_contrataciones_user_universidad]
[wpv-conditional if="( '[numero_contrataciones_user_universidad]' >= '2' )"]TEST[/wpv-conditional]

Display:
Numero contrataciones universidad: 2
TEST

Case 2:

Numero contrataciones universidad: [numero_contrataciones_user_universidad]
[wpv-conditional if="( '[numero_contrataciones_user_universidad]' < '2' )"]TEST[/wpv-conditional]

Display:
Numero contrataciones universidad: 2
(nothing)

Is that right????

#872873

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

This is a duplicate ticket.

Can you please close this one.

Thanks,
Shane