In Elementor Extras 2.0 we introduced Display Conditions. A very powerful way of conditioning the display of widgets and sections. These conditions range from user login to the current used WordPress template.
Elementor lets you create different templates for all pages in the WordPress template hierarchy. But sometimes these layouts can be very similar and you might only need a few changes from one to another. Instead of creating different templates and ending up with huge amounts of duplicate content and having to change it in two places, you can use Display Conditions to hide certain areas depending on the current page.
Let’s say you have two custom post types: conference and concert. For both you need similar layouts with a sidebar on the right side for the single view. On the concert post type you need to show a button “Get Tickets” that you don’t need for the conference post type. Normally, because of that button, you would need to create two different Elementor templates: one for the conference post type, one for concert, with the only difference being the extra button on the concert single view.
With Display Conditions you can create only one template, go to the Button widget and under Advanced > Extras turn on Display Conditions, select “Post Type”, then “is” as the operator and “Concert” as the post type. This means that the Button widget will only show when the current page is a concert post type. That simple!
Display Conditions currently can be currently applied to Widgets and Sections. For sections, we only hide them using CSS at this point. For widgets you have the option to hide them using CSS or prevent the output of the HTML code all-together.
The conditions can be found under Advanced > Extras. Turn on Display Conditions and a repeater field will appear with a single condition. Each condition has a type, an operator (“is” or “is not“) and a value. The conditions types and their available values are:
- Login status — User is or is not logged in.
- User Role — Current logged in user role. This is valid only if the user is logged in.
- Operating system — Current operating system used by the visitor
- Browser — Current browser used by the visitor
- Date & Time — If the current date or time
- Current date — is between or outside an interval
- Time of day — is between or outside of an interval. You can choose to show certain content at night each day, for example.
- Current Page
- Page — current page is one of the selected pages
- Post — current post is one of the selected posts
- Static Page — is the front page, homepage, blog posts page or 404 page.
- Post Type — is a single view of a post type
- Current Archive — If the current archive
- Taxonomy — is a specific taxonomy archive
- Post Type — is a custom post type archive
- Date — is a date archive. It can be “day”, “month”, or “year”.
- Author — is a specific author archive. You can leave the value empty for all author archive pages.
- Search — is a search results page. Moreover, you can show or hide it if the search query contains a certain word. This is powerful because it means you can show content for users based on the interest shown in a specific topic.
You are free to add as many conditions as you want. You can also specify wether these conditions should ALL be met, or should ANY of them be met under the Display on control. For the condition types where you can select multiple values, these values have an OR relationship. For example, if you add a condition: “Current Archive Taxonomy” + “is” and select both “Categories” and “Tags”, the element will display on a category archive page OR a tag archive page.