Need Help?

Here are some good places you cant start.

Whats New?

Get updated about all the good stuff!

wordpress-black-friday-deals-2025
Unlimited Elements for Elementor – Version 2.0
Unlimited Elements for Elementor – Version 2.0

Twig Code Example – If Else

Use an IF – Else condition in Twig to show one part of the HTML when a condition is true, and another part when it is false. You can add this code from Twig Code Examples > IF – Else in the widget creator. To learn how, see Showing twig code examples.

				
					{% if product_stock == 0 %}
	<!-- not available html -->
{% else %}
	<!-- available html -->
{% endif %}
				
			

In this example, product_stock is the name of an attribute. When its value is 0, the first part is shown. For any other value, the part after {% else %} is shown.

You can use these comparisons in the condition: == (equal), != (not equal), <, >, <= and >=. To check more than one condition, join them with and or or.

Another example, with a Radio Boolean attribute:

				
					{% if open_in_new_tab == "true" %}
	<a href="{{link}}" target="_blank">{{title}}</a>
{% else %}
	<a href="{{link}}">{{title}}</a>
{% endif %}
				
			

Hurray!

You got FREE access to the worlds leading widgets for Elementor page builder!

Download is just a click away

Get instant access to tons of Elementor goodies, completely FREE!