Tutorial Script wordpress delete, update, replace wordpress post

Susp3kt

Web Designer
Registered
Full Member
Freelancer
Web Designer
Creati un fisier .php in public_html (unde sunt folderele wp-admin,wp-content,wp-includes) iar dupa aceea accesati fisierul .php in browser.
Va recomand sa faceti un backup la baza de date inainte sa rulati scriptul.

PHP:
<?php
set_time_limit(0);
ini_set("display_errors", 0);
error_reporting(0);
  include_once "wp-config.php";
  include_once "wp-load.php";
  include_once "wp-includes/wp-db.php";

  $args = array(
              'post_type' => 'post',
              'orderby'   => 'id',
              'order'     => 'DESC',
              'post_status' => 'any',
              'posts_per_page' => -1,
);

$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { 
    while ( $the_query->have_posts() ) {
        $the_query->the_post();     

    $continut = get_the_content();
    $find_videomega = strpos($continut, "videomega.tv");

    if($find_videomega) {    
      $id_postare = get_the_ID();
      $continut_nou = preg_replace("/<iframe width=\"(.*?)\" height=\"(.*?)\" scrolling=\"no\" frameborder=\"0\" src=\"http:\/\/videomega.tv\/(.*?)\" allowFullScreen><\/iframe>/is", "", $continut);
       $my_post = array(
        'ID'           => $id_postare,
        'post_content' => $continut_nou,
      );

      wp_update_post( $my_post );

    }

    }
}

wp_reset_postdata();

EDIT:
Scriptul scoate doar codurile de embed din post content.
 
Loading...
Back
Sus