Solved my own issue thanks to some help on the main feedback form here: https://ww.wp.xz.cn/support/topic/how-to-disable-automated-wp-core-fetchpriorityhigh-application/#post-18464473
I was utilizing the following function hook for Generate Blocks to sort my posts by a custom meta date field:
//DATE type custom field value
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
// apply filter if loop has class: order-by-end-date
if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'order-by-end-date' ) !== false ) {
$query_args = array_merge( $query_args, array(
'meta_key' => 'end_date',
'meta_type' => 'DATE',
'orderby' => 'meta_value',
'order' => 'ASC',
));
}
return $query_args;
}, 10, 2 );
Due to the way it operates, it seems to keep the fetchpriority=high attribute that was applied by WP Core even after having another function run at priority level 99 to remove this attribute.
The following is my final code that removes the fetchpriority being added by WP Core, while still preserving the functionality of the meta date post order:
//DATE type custom field value
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
// apply filter if loop has class: order-by-end-date
if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'order-by-end-date' ) !== false ) {
$query_args = array_merge( $query_args, array(
'meta_key' => 'end_date',
'meta_type' => 'DATE',
'orderby' => 'meta_value',
'order' => 'ASC',
));
}
return $query_args;
}, 10, 2 );
add_filter( 'wp_get_loading_optimization_attributes', function( $attributes, $context ) {
if ( isset( $attributes['fetchpriority'] ) && $attributes['fetchpriority'] === 'high' ) {
unset( $attributes['fetchpriority'] );
}
return $attributes;
}, 11, 2 );
Hopefully this helps someone else out that is scratching their head on why they cannot get WP Core fetchpriority=high attributes removed from images pulled by Generateblocks queries.
If you are ordering your queries, place the unset function call at the end of your ordering functioning and set the priority to 11 (or 1 lower than whatever your priority is for your order function). This will fix the issue.
Thank you.
-
This reply was modified 1 year ago by
ken78.