Home Forums ACF PRO Rules based on category & post type not working


Rules based on category & post type not working

  • I have four galleries which use multiple ACF gallery fields to allow users to add selected images. The gallery fields are in a separate Field Group for each gallery. The galleries appear in a custom post galled Gallery. Each ACF Gallery has a separate field with a name appropriate to the gallery subject. The ACF gallery fields use the following Location rule:

    Post Type is equal to Gallery and
    Post Category is equal to <category name>

    The terms Gallery and <category name> are selected from drop downs.

    In three of my galleries this works fine. In the fourth gallery, on the edit page the gallery fields appear and work fine but – after these fields, the name of one of the other galleris appears and below this other gallery’s ACF Gallery fields also appear. The user can add images to those additional gallery fields.

    Where the galleries have the same name as the galleries in the original post they also contain the same images – where the name is unique to the other gallery there are no images.

    I cannot see any difference in the way these pages and field groups are set up but the problem only appears on one of the galleries. The rules are precisely the same apart from the different category.

    I could rebuild the misbehaving page but thought I would look here for help first.

  • I’m confused, are you saying that you have gallery fields that have the same “field name” on the same page?

  • Hi John
    In theory no – but because a gallery that should not be on that page according to ACF rules does actually appear the answer is yes. Or rather was yes as I have now changed them to unique values but the problem persists.

    The site is a local history site and covers four areas. Each area has subsections on People, Church, Leisure etc so I set it up as follows:

    4 field groups titled with the area of interest eg Elvington, Waldershare etc
    In each field group there are gallery fields with the names of the subsection ie People, Church, Businesses etc
    The rules for each field group say that the gallery fields should only appear on pages which have the category with the same name as the field group. Because of this I saw no harm in giving fields in different field groups the same names so
    Field group ‘Elvington‘ has a gallery field called ‘People‘.
    Field group ‘Waldeshare‘ also has a gallery field called ‘People
    The Gallery pages have categories corresponding to one of each town name.

    This works fine for three of the galleries – only the Gallery fields in the field group of that category appear in the gallery edit page. But for the fourth gallery is shows the fields for two galleries (towns) – including a sub-heading with that extra field group name – ie the edit page for Elvingtonalso has the gallery fields for Waldershare

    As it happens, on the front end this does not matter – I use an Elementor gallery and the drop down for which images to show dynamically – allows me to just choose the gallery fields for one category (Elvington, Waldershare etc). But it looks messy for the client in the back end and has the potential to confuse.

    The other thing I noticed is that where the extra gallery field shares a name with the gallery fields of the correct town the galleries are populated with the same images – where they are different, there are no images. You can add images to these extra fields but they do not surface on the front end nor do they get added to the galleries on the proper page for that town.

    In retrospect I should have put a qualifier in the name eg elvington_people and waldershare_people. So I edited those field names to correct that but it has made no difference. I even deleted the old field names from the database and the current incorrect field names from the errant gallery page. They just re-appear as soon as you try to edit that page. I attach two screenshots to help explain.

    What annoys me is that there appears to be no logic to this – why do three Galleries behave properly and only one is wrong? I tried deactivating all other plugins but it did not help.

  • I’m not exactly sure to be honest. It seems to me that there might be something wrong with the location rules for these extra group that are appearing where they should not.

  • Hi John

    Thanks for taking an interest in my issue!

    I really can’t see how it can be caused by location rules. I have checked again and the rules are as follows:

    Post Type is equal to Gallery and
    Post Category is equal to Elvington

    Gallery is a custom post created in code by me – and as I have said before the other Galleries work – the Rules for those galleries are exactly the same apart from obviously applying to another town in the drop down

  • Sorry, I’ve reread your descriptions several times and I can’t see anything in it that would be causing the issue of why fields are showing that should not me.

    Can you give me a screen shot of your location rules?

  • As requested

  • I haven’t got a clue. Sorry, but it seems my ability to help you is limited. You’ve definitely got something strange going on. I would contact the regular support

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.