Skip Navigation

[Gelöst] conditional output category doesn't work anymore

This support ticket is created vor 1 Jahr, 11 Monate. 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)

This topic contains 19 Antworten, has 3 Stimmen.

Last updated by Dido vor 1 Jahr, 10 Monate.

Assisted by: Shane.

Author
Artikel
#2368009
code.JPG
home.JPG
cat.JPG

Hi,

on hidden link I used conditonal (in a view) output for categories, but it stops working after the latest updates.
see image home

in archives it I did not use conditional output, for instance
hidden link see image cat

this is my code.
[wpv-conditional if="( CONTAINS(#(category),'0') )"]<span class="opsomming">[wpv-post-taxonomy type="category"]</span>[/wpv-conditional]
[wpv-conditional if="( CONTAINS(#(land),'0') )"]<span class="opsomming">uit [wpv-post-taxonomy type="land" separator=", "]</span>[/wpv-conditional]

#2368063

Shane
Supporter

Languages: Englisch (English )

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

Hi Dido,

Thank you for getting in touch.

Can you add debug ='true' to your conditionals and let me know what the debug statement says when viewing the page on the frontend?

Thanks,
Shane

#2368309

Hi Shane,

I added the debug code to the conditionals. you can see it on my homepage.

#2369363

Minesh
Supporter

Languages: Englisch (English )

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

Shane is on holiday today. He will get in touch with you tomorrow.

- Did you able to make it work? if no:
- Can you please share admin access details that will help Shane to check whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2370039

Shane
Supporter

Languages: Englisch (English )

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

Hello,

I checked on the page but not seeing any debug on the frontend.

Also when checking the archive on the backend i'm not seeing the conditionals below.

[wpv-conditional if="( CONTAINS(#(category),'0') )"]<span class="opsomming">[wpv-post-taxonomy type="category"]</span>[/wpv-conditional]
[wpv-conditional if="( CONTAINS(#(land),'0') )"]<span class="opsomming">uit [wpv-post-taxonomy type="land" separator=", "]</span>[/wpv-conditional]

Did you remove them ? If so can you re-add them so that I can check what is happening.

Thanks,
Shane

#2370065

Hi Shane,

very strange. I have the debug in hidden link
I saw the debug text earlier, but now I don't see it anymore.

[wpv-conditional if="( CONTAINS(#(category),'0') )" debug ="true"]<span class="opsomming">[wpv-post-taxonomy type="category"]</span>[/wpv-conditional]
[wpv-conditional if="( CONTAINS(#(land),'0') )" debug ="true"]<span class="opsomming">uit [wpv-post-taxonomy type="land" separator=", "]</span>[/wpv-conditional]

#2370081

Shane
Supporter

Languages: Englisch (English )

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

Hi Dido,

Are you checking if the post has any taxonomy attached to it and then displaying the term if it does ?

Please let me know if this is the goal.

Thanks,
Shane

#2370083

Yes, true. because of the dot

#2370203

Shane
Supporter

Languages: Englisch (English )

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

Hi Dido,

I see where you are using php 8.1.5, however just to ensure that this is not a compatibility issue with version 8.1 of php can you downgrade the server to 8.0 and let me know if the problem still persists?

I tried with using the has_term() function as well and the results remain the same.

Please let me know.

Thanks,
Shane

#2370641

hello Shane,

I downgraded tot 8.0.18 but the problem still remains.
After this, I downgrade to 7.4 and still the same.

#2370903

Shane
Supporter

Languages: Englisch (English )

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

Hi Dido,

It would appear that this isn't evaluating correctly or as expected.

I've crafted a workaround that uses the has_term function because this allows you to check if the post has at least 1 term from that taxonomy assigned.

Add the following shortcode to your website.

function checkforterm( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'post_id' => '',
            'taxonomy' => ''
		),
		$atts
	);

	return has_term('', $atts['taxonomy'], $atts['post_id']);

}
add_shortcode( 'checkforterm', 'checkforterm' );

Then you can craft your conditional like this.

[wpv-conditional if="( '[checkforterm post_id='[wpv-post-id]' taxonomy='category']' eq '1' )" debug='true']This should display[/wpv-conditional]

Finally just add the text 'checkforterm' in the 3rd party shortcode arguments at Toolset -> settings -> Frontend Content.

Please let me know if this helps.
Thanks,
Shane

#2373773

Hi Shane,

I added all the codes and now it partly works. How strange! In some tiles the category is showed, but in other tiles not.

#2374141

Shane
Supporter

Languages: Englisch (English )

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

Hi Dido,

Are you able to send me a screenshot of the tile that should show some information but isn't?

Thanks,
Shane

#2374191
single.JPG
cat-name.JPG

hi Shane,

Here you see an example. 1 = ok, 2 is not ok. When you click on the title, you go to the single post.
There you see the categorie names.

#2374559

Shane
Supporter

Languages: Englisch (English )

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

Hi Dido,

This one seems to be beyond Toolset as the category doesn't even show when using the Toolset taxonomy shortcode to get the current taxonomy.

Perhaps try to temporarily disable some of the non-toolset plugins and check again. There might be something that is preventing us from getting the taxonomy information for all your posts.

Thanks,
Shane

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