• Resolved topi_r

    (@topi_r)


    I have Persons CPT. All persons are handled via integration. Persons come and go and this leads to 404 problems.

    //Set absent persons to draft
    $args = array(
    'posts_per_page' => -1,
    'post_status' => 'any',
    'post_type' => 'person',
    );
    $persons = get_posts($args);

    foreach ($persons as $person) {
    if (!in_array($person->ID, $persons_in_API)) {
    wp_update_post([
    'ID' => $person->ID,
    'post_status' => 'draft',
    ]);
    }
    }

    I would like to create redirection after wp_update_post(). How can I achieve this?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add/Remove redirects programmatically’ is closed to new replies.