Elementor Element Condition

Some elements should not be displayed or must be displayed under certain conditions. This plugin gives the possibility to add a condition to an element.

Control what you show!

Description

  • This plugin adds the ability to add conditions to sections, columns or widgets in order to be shown or not.
  • You can add your own values in your function.php using add_filter()
  • This plugin is currently pretty basic, you can only use only 2 operands and one operator. No brackets and no AND / OR operators for now.
  • The use of $ sign in variables is optional 
  • Custom fields are automatically set as vars in condition.

Support

For string comparison don’t use the quotes delimiter:

$myvar == ‘good’

the right way:

$myvar == good

Ele Conditions - how to use

Below are some specific cases Ele-Conditions can be used for:

May be you have a countdown, section containing a promotion or whatever content that you won’t wanna show past a certain date you can use:

2018-11-04 00:00:00 > $now

where $now is the current date.

By default all the metadata of a post is transformed in variable. For example we have a custom field “twitter” and we want to show an element only if twitter custom field has value we can do it like this:

$twitter != null

or

$twitter != false

If you have a custom field or custom key you entered with add_filter() that has a numeric value you can compare it. If the value is null it will atomatic be 0.

If you want to he skin look diferent for each item you, now you can.

By default you can’t add more than one simple condition but you can add your own variabile like this:
/*adding custom values to conditions*/

add_filter( "eleconditions_vars",function($custom_vars){
	global $product;
	if ( isset( $product ) ) {
		if ( ! $product->managing_stock() && ! $product->is_in_stock() ) $custom_vars['instock']=false;
	else
		$custom_vars['instock']=true;
	}
	return $custom_vars;
});
and in condition to the add to cart element you enter:
$instock == true
In this way the add to cart button will show only if the product is in stock. Also you can use it in loop.

For example we would like to make a loop for the latest posts, but we want to add show a distinct element only if the user is john:

post_author == john

You can observe I didn’t use any quotes and it works without adding the dollar sign, but for good practice will recommend adding it.

Available variabiles

Every variabile would be replaced with the actual value from $wp_query or $post objects and custom fields

Here are some keywords that are commonly used in templates: 

Post Object:

$post_namestringThe post’s slug
$permalinkstringThe post’s permalink
$post_titlestringThe title of the post
$post_datestringFormat: 0000-00-00 00:00:00
$post_date_gmtstringFormat: 0000-00-00 00:00:00
$post_contentstringThe full content of the post
$post_excerptstringUser-defined post excerpt

Se more Values here:

https://codex.wordpress.org//Class_Reference/WP_Post

Query vars:

$pagenamestringPage name
$daystringDay
$minutestringMinute
$monthnumstringMonth format : 00
$sstringSearched word
$searchstringSearch
$yearstringYear
$category_namestringCategory name

See more vars here:

https://codex.wordpress.org//WordPress_Query_Vars

Custom fields:

For custom fields just put the slug of the custom field inside the condition.

Add your own values:

Add your own values to the conditions using addfilter in your functions.php:

/*adding custom values to conditions*/

add_filter( "eleconditions_vars",function($custom_vars){
	global $product;
	if ( isset( $product ) ) {
		if ( ! $product->managing_stock() && ! $product->is_in_stock() ) $custom_vars['instock']=false;
	else
		$custom_vars['instock']=true;
	}
	return $custom_vars;
});

Support

Keep in TOuch

Subscribe to our newsletter by entering your email and be the first to learn about new updates and features.

Elementor Element Condition