Created
March 24, 2021 15:30
-
-
Save guytzhak/e639985a9488ad44b8e3b2dca20e86fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( false === ( $customQuery = get_transient( 'projectName_related_products' ) ) ) { | |
$args = [ | |
'post_type' => 'post', | |
]; | |
$customQuery = new WP_Query($args); | |
set_transient( 'projectName_related_products', $customQuery, 99999 * HOUR_IN_SECONDS ); | |
} | |
add_action('woocommerce_update_product', function () { | |
$args = [ | |
'post_type' => 'post', | |
]; | |
$customQuery = new WP_Query($args); | |
set_transient( 'projectName_related_products', $customQuery, 99999 * HOUR_IN_SECONDS ); | |
}); | |
if( $customQuery->have_posts() ) { | |
while ($customQuery->have_posts()) { | |
$customQuery->the_post(); | |
//your code.... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment