Home Forums Backend Issues (wp-admin) Displaying Posts with Multiple Entries in Custom Field


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

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

You must be logged in to reply to this topic.