I have this query
[wpv-view name="des-moines" limit="-1" offset="0" locationid="465,471,205,198,469,467"] which should display 110 entries, but is only showing 100. 10 are missing. If you look at the pages where I should the individual locations I can account for all 110. Its only when I use this view to consolidate these locations together, it somehow misses 10.
You can view this query in action on
enlace oculto (production).
enlace oculto (cloned server)
I'm giving you access to a new clone that I just spun up so that you can easily diagnois problem. I will need to replicate any fix to the production service.
Hi, after migrating to the new post relationships system, the old _wpcf_belongs_location_id custom field cannot be used as a filter with any level of certainty. When posts are linked in this relationship after the relationship migration process, this custom field value will not be added to child posts in the relationship. The field will remain in place for posts that were linked before the relationship migration. In the new system, a proprietary data table is used to handle those relationship connections. So I suspect what is going on here is you have 10 items that were linked in this relationship after the relationship migration process was run, and now those items are not appearing in the list of results. That is a quirk of how WordPress filters work, unfortunately. If a custom field is used as a filter, but a post has no value for that custom field, it will not appear in the query results.
Thanks for setting up the staging site, that's very helpful. I can run a few tests on the staging site to confirm my theory, or look for other potential causes. Stand by and I will update you soon.
Thanks Christian. I guess I could build 6 different views (one for each location) and then display them together on the same page, they would just be independent of each other. Any other ideas appreciated.
That's an option, but I am trying to find a cleaner alternative that doesn't involve too much custom code. I'll have to follow up tomorrow as my day is ending here.
Okay here is an idea. This is a custom shortcode that will return a comma-separated list of child post IDs if you provide a list of parent post IDs and the slug of a post relationship:
add_shortcode('children-of-multiple-parents', 'children_of_multiple_parents');
function children_of_multiple_parents($atts, $content = '') {
$atts = shortcode_atts( array(
'parents' => '',
'relationship' => '',
'limit' => 1000000,
'offset' => 0
), $atts );
$children = toolset_get_related_posts(
// get posts related to this one
[
'parent' => explode(',', $atts['parents'])
],
// Relationship between the posts
$atts['relationship'],
// Additional arguments
[
// pagination
'limit' => $atts['limit'],
'offset' =>$atts['offset'],
//
'args' => [ ],
'role_to_return' => 'other',
'return' => 'post_id'
]
);
return implode(',', $children);
}
So you would create a View of child posts, filtered by post IDs set by a shortcode attribute "ids". Then you would use this custom shortcode in the View shortcode like this:
[wpv-view name="your-view-of-child-posts" ids="[children-of-multiple-parents parents='465,471,205,198,469,467' relationship='location_public-artwork'][/children-of-multiple-parents]"]
Thank you! I will try this later this week.