Title: ken78's Replies | WordPress.org

---

# ken78

  [  ](https://wordpress.org/support/users/ken78/)

 *   [Profile](https://wordpress.org/support/users/ken78/)
 *   [Topics Started](https://wordpress.org/support/users/ken78/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ken78/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ken78/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ken78/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ken78/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ken78/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[GenerateBlocks] Does Generateblocks automatically add fetchpriority=high attributes?](https://wordpress.org/support/topic/does-generateblocks-automatically-add-fetchpriorityhigh-attributes/)
 *  Thread Starter [ken78](https://wordpress.org/support/users/ken78/)
 * (@ken78)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/does-generateblocks-automatically-add-fetchpriorityhigh-attributes/#post-18464482)
 * Solved my own issue thanks to some help on the main feedback form here: [https://wordpress.org/support/topic/how-to-disable-automated-wp-core-fetchpriorityhigh-application/#post-18464473](https://wordpress.org/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:
 *     ```wp-block-code
       //DATE type custom field valueadd_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:
 *     ```wp-block-code
       //DATE type custom field valueadd_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, 1 month ago by [ken78](https://wordpress.org/support/users/ken78/).
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to disable automated WP Core fetchpriority=high application?](https://wordpress.org/support/topic/how-to-disable-automated-wp-core-fetchpriorityhigh-application/)
 *  Thread Starter [ken78](https://wordpress.org/support/users/ken78/)
 * (@ken78)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/how-to-disable-automated-wp-core-fetchpriorityhigh-application/#post-18464473)
 * [@yashjawale](https://wordpress.org/support/users/yashjawale/)
 *     ```wp-block-code
       add_filter( 'wp_get_loading_optimization_attributes', function( $attributes, $context ) {    if ( isset( $attributes['fetchpriority'] ) && $attributes['fetchpriority'] === 'high' ) {        unset( $attributes['fetchpriority'] );    }    return $attributes;}, 10, 2 );
       ```
   
 * Thank you for your assistance, I was able to fix the issue by modifying the priority
   of your code slightly and having it execute at the proper time.
 * I discovered I had a conflicting code that was merging attributes after they 
   were performed and I suspect after the fetchpriority=high attribute was already
   applied by WP Core. Even when running the your code separately at priority level
   99, it was not removing the fetchpriority=high attribute from those images.
 * The conflicting code I was using was a function hook for another plugin called
   Generate Blocks for ordering a separate query loop by a custom meta date field.
   This code is as follows:
 *     ```wp-block-code
       //DATE type custom field valueadd_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 );
       ```
   
 * In order to fix my issue, all I had to do was add your add code to the end of
   this code and set priority to 11. The following is my final code that fixed my
   issue of removing the automated fetchpriority=high attribute whilst still allowing
   me to order the query by custom meta field date:
 *     ```wp-block-code
       //DATE type custom field valueadd_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 );
       ```
   
 * Thank you all for your assistance, I’m marking this issue resolved now.

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