Home Forums ACF PRO Rule for selected posts within a custom post type


Rule for selected posts within a custom post type

  • I am trying to add a fieldgroup to selected posts and subposts within a custom post type in ACF PRO.

    In case of normal WordPress pages I could set an own page template but page templates do not exist for custom post types.

    I also can’t (ab)use a category or tag for this in the site in question.

    All these selected posts have one thing in common, a part of the postname (slug).

    Any ideas how I could create a rule with the above requirements?

    My suggestion for future versions of ACF PRO, add a rule for a postname pattern, either as regex or maybe more userfriendly like in CSS attributes [~=value], [^=value], [*=value], etc.

  • Talking to myself here, but for interested readers, found a solution now for this problem, via functions.php.

    For the following code a fieldgroup “Mygroup” is added to two custom post types “aaaa” and “bbbb” via ACF PRO.

    The javascript-code then hides that fieldgroup if not “xxxx” or “yyyy” appears in the slug of the posts of these post types.

    As WPML with 2 languages is used on the site, the code looks for the normal “acf-mygroup” and also “acf-mygroup-2” for the 2nd language, the fieldgroup has the same title in both languages.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.