Skip Navigation

[Resolved] Show item when a taxonomy contain a certain slug

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Noman 6 years, 8 months ago.

Assisted by: Noman.

Author
Posts
#561349
screenshot-decology.co.uk-2017-08-18-18-12-58.png

I am trying to display a <div> just if a certain taxonomy is ticked on.

Taxonomy name: Room status (room-status)
Taxonomy ticket: Revision 1 (revision-1)

My try:

[wpv-conditional if="('[wpv-post-taxonomy type='room-status' format='slug' ]' eq 'revision-1' )"]TEST[/wpv-conditional]
or
[wpv-conditional if="('[wpv-post-taxonomy type='room-status' format='slug' ]' in 'revision-1' )"]TEST[/wpv-conditional]

I expected to see: I expect to populate the TEST field with buttons to display in a flex container in order to fill the container with how many revisions a user needs for his project.

Instead, I got: with [wpv-post-taxonomy type='room-status' format='slug' ] I'm able to see them in order but not what's contained in it.

#561371

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Register_Custom_Shortcode & Function.png

Hi Vito,

We can achieve this by using custom shortcode. For this you need to create a Custom Search View >> and add Taxonomy filters as Radio options and style them as you like to >> then follow below instructions:

1. Please add this code in your theme’s or child theme’s functions.php file:

function get_selected_filter_fun( $atts ) {
  
    // Attributes
    extract(shortcode_atts(
        array(
            'taxonomy' => '',
        ),
        $atts
    ));
	
	if(isset($taxonomy))  {
		$term_value = 'wpv-'.$taxonomy;
		if( isset($_GET[$term_value]) && $_GET[$term_value] != ''){
			return $term_value;
		}
	}
	else
		return '';
         
}
add_shortcode( 'get_selected_filter', 'get_selected_filter_fun' );

2. Register shortcode & function first ‘get_selected_filter’ in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments. And also in >> Functions inside conditional evaluations section -- screenshot attached.

3. Then you can use shortcode in the View like this:

 
[wpv-conditional if="('[get_selected_filter taxonomy=room-status]' eq 'revision-1' )"]TEST[/wpv-conditional]

==> Whereas “room-status” is the taxonomy name and 'revision-1' is taxonomy term.

Thanks

The forum ‘Types Community Support’ is closed to new topics and replies.

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