• Resolved Beee

    (@beee)


    I’d like to remove all custom set SEO titles with a simple function.

    I think it should be something like this, but I can’t manage (yet).

    $post_args = array(
        'post_type'      => 'event',
        'posts_per_page' => -1
    );
    $posts = get_posts( $post_args );
    
    if ( $posts ) {
        foreach ( $posts as $item ) {
    
            // remove $item->_yoast_wpseo_title
            // remove $item->custom->_yoast_wpseo_title
    
        }
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • AFAIK – Yoast saves custom SEO titles into the meta value “_yoast_wpseo_title” so this should be your solution:

    WARNING: Untested.

    
    $post_args = array(
        'post_type'      => 'event',
        'posts_per_page' => -1
    );
    $posts = get_posts( $post_args );
    
    if ( $posts ) {
        foreach ( $posts as $item ) {
            delete_post_meta($item->ID, '_yoast_wpseo_title');
        }
    }
    
    Thread Starter Beee

    (@beee)

    *incorrect statement

    • This reply was modified 7 years, 9 months ago by Beee.
    Thread Starter Beee

    (@beee)

    I think your solution works though… will test now.

    • This reply was modified 7 years, 9 months ago by Beee.
    Thread Starter Beee

    (@beee)

    Works, thanks John.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove all SEO titles’ is closed to new replies.