Site logo

[Support request] Display block element if post meta equals certain value

Home Forums Support [Support request] Display block element if post meta equals certain value

Home Forums Support Display block element if post meta equals certain value

  • This topic has 5 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1726625
    Greg

    Using GP2.0 is fantastic but I wanted check if there’s a way I can display a block element (or hide a container within one) depending on the value of an ACF field (eg. display if ACF = “Yes”)? Right now it seems like I can only check whether a field exists, not the value of it.

    #1727894
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You can use the “Remove container condition” option in the Container block when it’s inside a Block Element. Then choose “No post meta”, and input the meta field name.

    This will remove the Container if that post meta value doesn’t exist.

    Let me know if that’s what you’re after or not 🙂

    #1730236
    Greg

    That is actually really useful and would work fine for lots of things I have planned.

    I think it would still be very useful to have “post meta equals X” so that different post options can be displayed as a drop down. That would allow me to create things that would normally require code.

    #1731340
    Tom
    Lead Developer
    Lead Developer

    Would this be in the Display Rules? So the entire Element displays based on a post meta value for the requested page?

    #1731405
    Greg

    I think it would be better on a container level to give more control.

    To give you an example, https://collectiveanimalrescue.co.uk/adopt/guineapigs/ has cards based on an animal. There are different styles, colours and icons depending on whether an acf dropdown field is equal to different values.

    Being able to show the container depending on post meta value would be incredibly useful.

    I also wanted to check whether it would be possible to add the current user meta into this so we could easily create user dashboards with this and acf.

    #1732800
    Tom
    Lead Developer
    Lead Developer

    Adding Display Rules like this into the actual Container block would become quite complex, but definitely not impossible. I’ll give it some thought 🙂

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.