• Gemini23

    (@gemini23)


    Having had YARPP manualy ‘un-ticked’ on several thousand posts – is it possible to automatically switch YARPP back on for these posts?

Viewing 1 replies (of 1 total)
  • Thread Starter Gemini23

    (@gemini23)

    Okay - re the following code - what do I change the 'POST_TYPE_HERE' to? And anything else need changing?
    
    Most posts in 1 of 2 different categories.
    
    add_action('init', 'bulk_update_post_meta_data');
    
    function bulk_update_post_meta_data() {
    
    // guardrail: if current user can't edit posts, bail
    
    if ( ! current_user_can( 'edit_posts' ) ) return;
    
    $args = array(
    
    'posts_per_page' => -1,
    
    'post_type' => 'POST_TYPE_HERE',
    
    'suppress_filters' => true
    
    );
    
    $posts_array = get_posts( $args );
    
    foreach($posts_array as $post_array) {
    
    $yarpp_meta['yarpp_display_for_this_post'] = 1; // YARPP value to update
    
    update_post_meta( $post_array->ID, 'yarpp_meta', $yarpp_meta );
    
    }
    
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.