• Resolved pstidsen

    (@pstidsen)


    Hi there,

    I import WooCommerce products using WP All Import (and the WP All Import – Yoast WordPress SEO Add-On is activated). However, I need to resave all products manually in order to get a readability score and in order to show a correct breadcrumb. That has been OK, but the store is growing and now hundreds of products can be uploaded at once. Therefore, I am wondered whether it is possible to call the necessary hooks by code? I have tried calling the wp_update_post function and doing the save_post action. However, that does not set the readability score for the products.

    Can you help me further?

    function resave_unresaved_products() {
    // Check if the specific URL parameter exists and has the correct value
    if (get_query_var('resave_unresaved_products') === 'true'){
    // Arguments to query only posts that do not have the _yoast_wpseo_content_score meta field
    $args = array(
    'post_type' => 'product',
    'numberposts'=> -1,
    );

    $products = get_posts($args);

    if ($products){
    echo count($products) . ' products need resaving.<br>';
    foreach ($products as $product){
    //Method 1 tried:
    $product->post_title = $product->post_title . '';
    wp_update_post($product);

    //Method 2 tried:
    do_action('save_post', $product->ID, $product, true);
    echo '<br>Resaved product: ' . $product->ID . ' - ' . $product->post_title;
    }
    } else {
    echo 'No posts needs resaving.';
    }
    }
    }

    // Hook the function to the 'wp_loaded' action
    add_action('wp_loaded', 'resave_unresaved_products');
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hi @pstidsen

    The analysis only runs in real-time when the post/product is open in edit mode.

    Thank you for suggesting a new feature for one of our plugins! You’re not the first to have requested this feature! That means a feature request has been created internally and is under review by our product team.

    What’s next?
    Our product team will assess the feature request and assign a priority level to the report. Our developers work on the highest priority issues first. We cannot give you an estimate of when or if they’ll start working on the request.

    Thread Starter pstidsen

    (@pstidsen)

    Hello,

    Thanks for your reply. It could be nice, if your scores, breadcrumbs and stuff like that, was updated on ‘wp_update_post’ or something like that.

    Until then, I have set up a routine in Power Automate which can loop through the products and click the button ??

    Best Regards,
    Peter B. Stidsen

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Imported posts need resaving before showing readability score’ is closed to new replies.