Forum Replies Created
-
AuthorPosts
-
milena_u6jm
ParticipantOK, so have attached two lists for you, one is the data from the ignore list, and the other is a report with the available media ids. These look ok, the avialables are newer ids, and the ingores are all older.
But there’s one thing that looks wrong… The ignore list is only 1153 entries. There are 7700 media items, and with only 370 avialables, shouldnt the ignore list be closer to 7300?
I deleted the ignore list, and rebuild the index, comes back with the same amount again.
milena_u6jm
ParticipantHey Ernest,
Hope you had a good break!
So back on this now, here is my current snippet:
add_filter('asp_index_post', function( $post ) { if ( $post === null ) { return $post; } // Only apply this filter to attachments (media) if ( $post->post_type !== 'attachment' ) { return $post; } $meta_key = 'available'; if ( function_exists('get_field') ) { $available = get_field( $meta_key, $post->ID, false ); // ACF support } else { $available = get_post_meta( $post->ID, $meta_key, true ); } // Check if the field exists and is truthy (1, "1", true, "yes", etc.) if ($available === true || $available == '1') { return $post; } return null; }, 10, 1);But its only returning 25 results. When re-creating the index, it also seems to run slowly, then go from like 10% to completed instantly, which feels a bit out, like its getting stopped?
When I run this logic against the database in a script, I get 370 results, which is the correct amount of results:
if ($total_media > 0) { foreach ($media_ids as $id) { /** * 2. Check the ACF field 'available'. * ACF usually stores booleans as '1' (true) and '0' (false) in the DB. * get_field() handles the logic correctly. */ $is_available = get_field('available', $id); if ($is_available === true || $is_available == '1') { $available_count++; } else { $unavailable_count++; } } }So I think the available logic is right, but something else is happening?
Let me know, thanks.
milena_u6jm
ParticipantThanks my friend, that one is resolved by adding those two fixes. Love your work!
milena_u6jm
ParticipantThanks Ernest for your help!
I have added the following code but its not getting the desired results.
add_filter('asp_index_post', function( $post ) { if ( $post === null ) { return $post; } // Only apply this filter to attachments (media) if ( $post->post_type !== 'attachment' ) { return $post; } $meta_key = 'available'; if ( function_exists('get_field') ) { $available = get_field( $meta_key, $post->ID, false ); // ACF support } else { $available = get_post_meta( $post->ID, $meta_key, true ); } // Check if the field exists and is truthy (1, "1", true, "yes", etc.) if ( !empty($available) && $available !== '0' && $available !== 0 ) { return $post; } return null; }, 10, 1);When I run the logic to just list results, I get 717 items, which seems right. But when I delete and re-index, its only return 74 items.
Anything we can try here? I’ve add some login info to the ticket if that helps.
Let me know, thanks.
Seamus
-
AuthorPosts