// SOLO LE SCHEDE LISTING $post_types = ['listing', 'lp-listings']; $posts = get_posts([ 'post_type' => $post_types, 'posts_per_page' => -1, 'post_status' => 'publish' ]); $total = 0; foreach ($posts as $post) { $title = sanitize_text_field($post->post_title); $url = get_permalink($post->ID); // META SR_ / LP_ / LISTING_ $meta = get_post_meta($post->ID); $meta_text = ""; foreach ($meta as $key => $values) { if (preg_match('/^(sr_|lp_|listing_)/', $key)) { foreach ($values as $v) { if (!empty($v)) { $meta_text .= "$key: $v\n"; } } } } // TASSONOMIE $taxonomies = ['sr_regioni', 'sr_categorie', 'region', 'location', 'listing-category']; $tax_text = ""; foreach ($taxonomies as $tax) { $terms = wp_get_post_terms($post->ID, $tax); if (!is_wp_error($terms)) { foreach ($terms as $t) { $tax_text .= "$tax: {$t->name}\n"; } } } // CONTENUTO WPBAKERY $raw = apply_filters('the_content', $post->post_content); $raw = strip_shortcodes($raw); $content_clean = wp_strip_all_tags($raw, true); // FULLTEXT $fulltext = " TITLE: $title URL: $url === CATEGORIE / LOCATION === $tax_text === META DATI === $meta_text === DESCRIZIONE === $content_clean "; $wpdb->insert($table, [ 'url' => $url, 'title' => $title, 'content' => sanitize_textarea_field($fulltext) ]); $total++; } La Villa Archivi - tiassisto.it
image

Strutture in La Villa Trova la tua!

Vedi I Filtri
TiAssisto Chat