Logo
Logo

Template Conditions

What Are Template Conditions in Breakdance

In Breakdance, while templates allow you to design and layout your content, template conditions give you the power to specify precisely where those templates are applied. This level of specificity ensures that certain designs or layouts only show up in desired areas or under certain circumstances, making your website both dynamic and user-specific.

For instance, you might have a range of posts on your website, and you want a specific design or layout to only apply to a subset of those posts. Breakdance’s template conditions come into play here, letting you pinpoint exactly which posts get that design.

Using Template Conditions in Breakdance

Setting Up Basic Conditions

  1. Start by logging into your WordPress dashboard and navigate to Breakdance -> Templates.
  2. Choose to add a custom template and give it a suitable name.
  3. Define that the template should apply to single posts.
  4. To refine its application, click Add Condition.
  5. Now, add a condition.

Using Multiple Conditions with AND and OR

Adding an AND Condition

  1. With an AND condition, both conditions must be true for the template to apply. As an example, if you set conditions like “Post Is [specific post]” AND “User Login Status is Logged In”, the template will only appear for logged-in users viewing that exact post.
  2. To add an AND condition, click the AND button.

Adding an OR Condition

  1. The OR condition means that only one of the conditions needs to be true. You could combine conditions such as “Post Is [specific post]” OR “Author Is [specific author]”. This ensures the template will apply if either of those conditions holds true.
  2. To add an OR condition, click Add Condition.

Verifying Your Conditions

  1. After setting your conditions, visit the front end to check them.
  2. Inspect the posts or pages where the conditions should be in effect and confirm. Using the example above, the specific design should be visible only on the designated posts for logged-in users or if the post’s author matches the given condition.

 

Default Conditions

Here’s a brief overview of the condition types available for Breakdance templates and how they work:

  • Singular
    • Post: Apply the template based on whether the post is or is not one of a given list of posts.
    • Post Parent: Apply the template based on the currently viewed post’s parent.
    • Has Taxonomy: Apply the template based on whether the currently viewed post has a specified taxonomy or taxonomies.
    • Post ID: Apply the template based on whether the currently viewed post’s ID is or is not a specificied post ID.
    • Post Status: Apply the template based on the currently viewed post’s status.
    • Comments Number: Apply the template based on how many comments the currently viewed post has.
    • Author: Apply the template based on the author of the currently viewed post.
    • Featured Image: Apply the template based on whether the currently viewed post has a featured image or not.
  • User
    • User Logged In Status: Apply the template based on whether the user is logged in or not.
    • User Role: Apply the template based on the user’s role (e.g., Subscriber, Contributor, Author).
    • User Registration Date: Apply the template based on when the user registered on the site.
  • Other
    • Dynamic Data: Apply the template based on dynamic data generated by other plugins or functionalities.
    • Custom PHP: Apply the template using custom PHP conditions or functions.
    • Browser: Apply the template based on the user’s browser (e.g., Chrome, Firefox, Safari).
    • Operating System: Apply the template based on the user’s operating system (e.g., Windows, macOS, Linux).
  • Date & Time
    • Day Of Week (WordPress): Apply the template based on the current day of the week according to your WordPress site’s settings.
    • Current Time (WordPress): Apply the template according to the current time according to your WordPress site’s settings.
    • Current Date (WordPress): Apply the template based on the current date according to your WordPress site’s settings.
    • Post Date: Apply the template based on the publishing date of a post.
    • Post Modified Date: Apply the template according to when a post was last modified.
    • Current Month (WordPress): Apply the template based on the current month according to your WordPress site’s settings.
  • Referrer
    • Referrer URL: Apply the template based on the URL the user came from.
    • Referrer Type: Apply the template depending on the type of referring source (e.g., search engine, direct link, social media).
  • Sessions
    • Page View Count: Apply the template based on the number of pages a user has viewed during their session.
    • Session Count: Apply the template according to the number of sessions a user has had on the site.

Custom PHP Conditions

You can also use Custom PHP conditions in Breakdance. The Custom PHP Conditions article discusses this and provides some examples.