• Resolved pradg

    (@pradg)


    Hi,

    I am building a database of devices. I have a Custom Post Type with ACF fields “Manufacturer” and “Year of Manufacture”. I want to create a separate page for each of the different manufacturer where the AQL can pull in the Post title and Year of Manufacture for that manufacturer. Format will be

    Post title – year of manufacture

    For example lets say I am creating a site which has the specifications of smart watches. So my Custom post type can have ACF fields Manufacturer and Year of Manufacture. i make a post for Samsung smartwatch with the title “Samsung smart watch galaxy 1” and ACF field Manufacture will have value “Samsung” and Year of Manufacture will have value “2025” and the query should display these entries in descending order. How do I create the query so that on the page, the query shows the post title and Year of manufacture for all posts under samsung?

    I tried building the meta query but it’s not working and I am unable to figure it out. I have exposed the field to the REST api

    Thanks.

    • This topic was modified 1 year ago by pradg.
    • This topic was modified 1 year ago by pradg.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter pradg

    (@pradg)

    Also how does one even output a ACF field in a query block?

    Thread Starter pradg

    (@pradg)

    Figured it out.

    Here’s what I did in case someone is looking for a similar solution.

    1. Create custom fields “Model Name”, “Manufacturer”, “Year of manufacture”.
    2. Install a plugin called “Blocks for ACF Fields” which pulls/displays the ACF field values. super plugin.
    3. Add two instances of the Blocks for ACF Fields inside the query loop. Set the first to fetch the Model Name and second to fetch the Year of Manufacture. I didn’t bother with the Post Title and added the same info in the Model Name custom field.
    4. Within AQL settings, add 2 Meta Queries. One in which you put the “Year of Manufacture” as the Meta Key and second in which you put the Manufacturer as the Meta Key and “Samsung” as the Meta Value. You can have any entry in the manufacturer (Apple, Samsung, Vivo, LG etc) and when you input that as the Meta Key, it’ll pull all the entries associated with that Manufacturer.
    5. Post Order By “Meta Value Num”.

      Amazing plugin Advanced Query Loop.

    Thanks.

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

The topic ‘Meta Query help needed (ACF)’ is closed to new replies.