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
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.
/*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 == trueIn 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_name | string | The post’s slug |
$permalink | string | The post’s permalink |
$post_title | string | The title of the post |
$post_date | string | Format: 0000-00-00 00:00:00 |
$post_date_gmt | string | Format: 0000-00-00 00:00:00 |
$post_content | string | The full content of the post |
$post_excerpt | string | User-defined post excerpt |
Se more Values here:
Query vars:
$pagename | string | Page name |
$day | string | Day |
$minute | string | Minute |
$monthnum | string | Month format : 00 |
$s | string | Searched word |
$search | string | Search |
$year | string | Year |
$category_name | string | Category name |
See more vars here:
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.