Home › Forums › Backend Issues (wp-admin) › Displaying Posts with Multiple Entries in Custom Field
Hola,
I am using Elementor and ACF and can get posts with individual entries to display, but can’t get posts to display if they have multiple entries in a custom field.
Here’s a basic idea of the problem
Partners is a post type.
Each Partner can attend multiple Seasons of our events, they have a ‘select’ for season.
I need to display Partners on the events page, but if they have more than 1 entry in the custom field, it won’t display.
ie. Mandy has been to season 1 and 5. If I set her as ONLY season 1, she will come up with a query of season 1. If I set her as attending 1 AND 5, Mandy won’t come up in a query of either season 1 OR 5….
I have a ton of relational fields and similar custom fields with multiple entries and this is causing a problem I cant seem to figure out.
Why can’t I do
field – fam_season
value – 1, 5
To be clear, are you using a relationship field or a post object field?
What is the code you are using to perform the query?
Hello, I am having the issue when using relational fields as well as general posts if the custom field/relational field has more than one entry.
I am using Elementor and ACF to pull posts up. If a ‘Partner’ has been to multiple events, the custom field then has multiple entries, such as ‘1, 5’ and then if I try and pull up ‘Season 1’ attendees, they no longer pull if if the field has more than one entry.
• Source: Partners
• Advanced Query Options-
– Custom Field Value
• Custom Field Options
– Custom Field is Value
• Field Name: fam_season
• Field Value: 1
Sorry, I missed the part about using Elementor.
To be honest, I don’t know how it is working at all, even when the field has a single entry. Elementor does not work well with relationship fields.
Elementor is expecting the custom field with a value that is equal to “1”. ACF does not store values like this for a relationship field.
When ACF stores the relationship with 1 entry and the value is “1” the value in the DB will look like this a:1:{i:0;s:1:"1";}
and when ACF stores multiple entries like “1” and “15” it would look like this a:2:{i:0;s:1:"1";i:1;s:2:"15";}
I can only guess that Elementor is somehow unserializing the single value and seeing it is an array with only one value and using that value correctly but not managing the multiple value return properly.
Querying posts by a relationship field is not something you can do without adding a custom query. See Querying relationship fields
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
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.