Query to find all object with a certain custom field value
See original GitHub issueHello,
My request is, I have different Post Types and some of them are linked. ( I have my post type “place” and my post type “news”, one news is linked to a place via a custom field )
On my “Place” page, I’d like to list all the news related to it. What I do for the moment is I created a Helper function, which finds all the news for the place. My worry is I’m doing a query which is too long to execute :
mesAnims = CamaleonCms::Site.first.posts.sort_by_field("date-de-debut", "desc").where(post_type: 69)
In other words, i find all the news. And then I do a loop to get only the ones for my current item.
`lesAnims = []
mesAnims.each do |anim|
if !anim.get_fields('bistrot-associe',0)[0].nil? && anim.get_fields('bistrot-associe',0)[0] == @post.id.to_s
lesAnims.push(anim)
end
end`
I would like to know if I could avoid this loop to directly add a “Where mycustomfieldslug = myvalue” . Thanks a lot,
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Search for a field in all objects - Salesforce Stack Exchange
The easiest way to do this is to open the Developer Console, click the Query Editor tab, check the "Use Tooling API" checkbox,...
Read more >SOQL query to get custom field in standard object from ...
Hey, I have a Custom object (custom_object__c) with a Lookup field for (Contact) from which I would like to get a field or...
Read more >Advanced search reference - JQL fields | Jira Software Cloud
Search for issues where a particular custom field has a particular value. You can search by custom field name or custom field ID...
Read more >Query posts by custom fields - ACF
This article will demonstrate how to retrieve an array of post objects from the database using native WP functions. There are many ways...
Read more >Find Objects by Custom Field - Alation APIs
This API allows you to find objects in the catalog by their custom fields. Note: Custom fields applied from catalog sets are not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

custom_field_slug is the DB column name to save the custom_field key. Example:
Check image for the structure:
Please bundle update, I released another version with the changes *.11
Hi @floreasy I improved this part and also I added small docs (sorting, filtering, preloading) here: http://camaleon.tuzitio.com/documentation/category/40756-uncategorized/custom-fields-1.html Please review and let me know if it works well for you.