Can you explain his to do a conditional if an acf field is empty,? For me that doesn’t seem to be an option. Without that I’m pretty much back 58 building my own custom templates.
That’s basically what I was asking for in my third bullet. I don’t think it’s possible in Beta 5. I’m excited about the possibilities it would open up though, as it would let you turn off whole sections of a layout based on a single ACF or CPT field.
––
@alexander, I like where you’re going with the “contains, not contains, is empty, is not empty” stuff. In Oxygen, they have something similar – however, I prefer the clarity of your “is empty” wording over their == !=
syntax.
––
Here’s a related use case. On one client’s site, I want to have an element that shows the Post Author’s name and link to their bio. However, there’s an author whose posts I would not want to show that particular element. So, it would be useful to be able to target specific authors (either through a drop down, or an open text field paired with “equals, contains, does not contain, etc”)
Totally agree about conditional display based on content of a field/custom field - I have been doing this until now with custom templates and my own shortcodes, which works fine, but I was hoping to get away from that with this new approach.
Sorry, it’s not an option yet. I was hoping to have some of this discussion first before adding any more functionality so we could talk through more real world use cases before building it out.
@devinelston I’m tracking with you! I think we can get something like that working.
@spedney thanks! Helps to know how you’re already solving it, and this this would be a good solution.
I was just building a blog archive page, which I assigned to show for the main blog as well as any archive pages.
However, for the title element on the page, I want to have slightly different versions depending on whether you’re viewing the primary blog or an archive. However, when I go into the conditions for the elements, there are not options for Blog is being viewed
or All Archives
like the assignments for the layout itself.
I had been expecting to be able to tap into the same sort of conditions – is there a reason why they don’t include all the same options?
I am playing with WooCommerce element Conditions. These are fantastic!
There is one common scenario which is missing, but it is supposed to happen live and I’m not sure if conditions could cover it:
If the cart totals is <
, >=
, >
than X, then show an element. This is important for example when free shipping is starting from, say $100. and the visitor has already added $80 value to the cart. A message appears that nudges him to add the remaining $20.
We might be able to add some of those back. The problem is that if a condition is used inside a looper, the WordPress Query data changes and it isn’t 1:1 the same as the assignment rules.
@Misho, Adding number comparisons like that could be possible. I don’t think we can wrap that up in this release since, but I’m adding it to our list. One thing to keep in mind is that the WooCommerce cart total is not always accurate. It can only run the condition on full page loads so if a cart item is added with the AJAX cart, that message would not go away.
@alexander, it is great to hear that it would be possible. If I was using some scripts before, like this one: https://jeroensormani.com/showing-add-10-free-shipping-notice/.
The more Pro will be able to support Ecommerce Conversion Optimization, the greater option it will be.
Here’s another one:
Conditions based on URL parameters. Again, not sure how this fits into the entire current system.
This is huge though. It would allow things like showing messages for specific campaigns, and also showing discount code options only to those who actually qualify for them, leaving them hidden for everyone else. This is yet another effective Ecommerce CRO trick.
This is also relatively easy to do with some functions.php scripts, but it is cumbersome and not very scalable.
Great idea! That could be another one for the string includes/excludes. We could do the whole URL, or perhaps expose query params or something like that.
Quick update on this. The next beta will have a “Featured Image [is / is not] set” condition, but I’ve not created any other rules yet.
Good afternoon my friends, wanted to post a quick update here. We added a couple more conditions in beta8 related to Loopers. For example, you can output an element if it [is/is not] the first, last element or even/odd elements. This will help with adding things like separators in-between looper elements.
For the 4.0.0 update we’re not introducing any more conditions. I’ve got a list going for what could be a smaller “conditional logic” update with much of what we discussed above like string and URL based conditions.
Awesome! I was wondering what those were for.
I know Conditions list are mostly done for the release, but one thing crossed my mind:
Show/hide elements is showing/hiding them using CSS, which means they are still loading in the browser, even if hidden.
Conditions are disabling stuff from what I understood. So would it be possible to add conditions based on the Viewport width as well?
Thanks!
Hey, @Misho! Great thought, but this is unfortunately not possible. The conditions allow you to hide things based on immutable characteristics within a singular page load. For instance, we can easily check if a featured image is set or not, and then choose to show variations in markup based on that because that will never change within a user’s session in the browser. This condition is checked before the markup is even generated, and it alters the markup accordingly based on the conditions we’ve set. So if we have a post that doesn’t have a featured image set, it’s not just “hiding” the featured image markup we want gone, it’s physically removing it from the markup and it can’t be generated until:
- An image is set, and…
- The user refreshes the page after the image is set.
With responsively showing and hiding Elements as the viewport changes, we have to use CSS because a user may or may not resize their browser up and down multiple times in a session, or change from portrait to landscape within the same session, et cetera, and the only way to juggle the changes in layout we need for this type of change is CSS.
Hey everyone, with the release candidate being imminent we have pushed the new documentation live. Here’s a helpful article on this subject: https://theme.co/docs/conditions-and-assignments
I’ll just carry on writing custom shortcodes in the meantime to do this, but a good example of a typical use case for me is I have a list of staff members, with photo, name, job title, phone number etc…
When I display phone number it will look like this:
Tel: 123 45 678
But if the data field for the phone is blank it will look like this:
Tel:
I would prefer just to not show that element at all if the data doesn’t exist.
Gotcha, definitely a good case for some kind of string matching which we’re planning on coming back to. For example, it could run Dynamic Content and see if the result is empty or has some kind of value match.
We definitely need conditionals for post metadata / ACF fields.