I have a Custom Post Type with comments. I just bought ACF Pro 5 to be able to attach Advanced Custom Fields to those comments, but I don’t get it to work.
Post Type is equal to [The post type] and
Comment is equal to All.
I’m also looking for some clarity with this. I can get the field to display on all comments (by using the “comments -> all” conditional. However, like ramvi, if I add a content type the field doesn’t display.
Is there any way to control what Post Types the ACF fields display on for comments?
To further clarify, a use-case:
Regular Posts (blog posts) use standard comment fields, however, a Custom Post Type “Review” might need a rating field.
When matching the rule, you can get the comment id from $options['comment'] variable. After that, you can use the get_comment() function to get the comment object and check if the comment is in a certain custom post type.
James, you’re a rock star. That worked near perfectly. The only problem was that the $options['comment'] didn’t really contain any useful information — it only returns a string related to the state of the comment form (I only tested it on a new comment and it said “new”).
But that wasn’t hard to work around by getting $post as a global and grabbing the $post->post_type value for comparing.
For anyone else looking to do this, here’s the complete code that I used and appears to be working. You’ll just need to stick that in your functions.php.
James, thanks again.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users