wmaraci reklam
lidertakipci

Wordpress Eklenti Yardım

2 Mesajlar 341 Okunma
advertseo
wmaraci reklam

eypclk eypclk WM Aracı Kullanıcı
  • Üyelik 08.02.2023
  • Yaş/Cinsiyet 24 / E
  • Meslek Öğrenci
  • Konum Konya
  • Ad Soyad E** Ç**
  • Mesajlar 2
  • Beğeniler 0 / 0
  • Ticaret 0, (%0)

Arkadaşlar merhaba, aşağıda wordpress eklentisi için bir kod yazdım basit bir html formu ile çalışıyor. Wordpresste tüm yazılardaki kelimeleri tarayıp yeni kelime listesindeki kelimeler ile tek tek değiştirerek yeni yazılar oluşturuyor.

Benim sorunum şurada başlıyor; Kod elementor ile düzenlenen yazıları taramıyordu başta sonrasında elementor için de bir kod satırı ekledim fakat bu seferde elementor ile oluşturulan yazının yapısını bozuyor.

Elementordaki yapıyı koruyarak yeni yazı oluşturmasını nasıl sağlayabiliriz? Yol gösterebilecek, bilgisi olan varsa yardımcı olabilir mi? Bi kaç gündür uğraşıyorum yapamadım maalesef.

function replace_words_in_posts_and_create_new_post($search_word, $replace_words) {
    $args = array(
        'post_type' => 'post', // articles only
        'post_status' => 'publish',
        'posts_per_page' => -1
    );
    $posts = get_posts($args);
    for ($i = 0; $i < count($replace_words); $i++) {
        foreach ($posts as $post) {
            $content = $post->post_content;
            $title = $post->post_title;
            if(strpos($content, $search_word) !== false || strpos($title, $search_word) !== false){ 
                $content = str_replace($search_word, $replace_words[$i], $content);
                $title = str_replace($search_word, $replace_words[$i], $title);
                $new_post = array(
                    'post_title' => $title,
                    'post_content' => $content,
                    'post_status' => 'publish',
                    'post_author' => $post->post_author,
                    'post_type' => $post->post_type
                );
                wp_insert_post($new_post);
            }
        }
    }
}


function replace_words_in_elementor_posts_and_create_new_post($search_word, $replace_words) {
    $args = array(
        'post_type' => 'elementor_library', // elementor posts only
        'post_status' => 'publish',
        'posts_per_page' => -1
    );
    $posts = get_posts($args);
    for ($i = 0; $i < count($replace_words); $i++) {
        foreach ($posts as $post) {
            $content = $post->post_content;
            $title = $post->post_title;
            if(strpos($content, $search_word) !== false || strpos($title, $search_word) !== false){ 
                $content = str_replace($search_word, $replace_words[$i], $content);
                $title = str_replace($search_word, $replace_words[$i], $title);
                $new_post = array(
                    'post_title' => $title,
                    'post_content' => $content,
                    'post_status' => 'publish',
                    'post_author' => $post->post_author,
                    'post_type' => $post->post_type
                );
                wp_insert_post($new_post);
            }
        }
    }
}



Mesaj 1 defa düzenlendi. Son düzenleyen: eypclk (10.02.2023 17:21)

 

 

wmaraci
reklam

eypclk eypclk WM Aracı Kullanıcı
  • Üyelik 08.02.2023
  • Yaş/Cinsiyet 24 / E
  • Meslek Öğrenci
  • Konum Konya
  • Ad Soyad E** Ç**
  • Mesajlar 2
  • Beğeniler 0 / 0
  • Ticaret 0, (%0)

++++++++++

 

 

wmaraci
Konuyu toplam 1 kişi okuyor. (0 kullanıcı ve 1 misafir)
Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al