| @@ -75,21 +75,9 @@ | ||
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | foreach ($data['titles'] as $key => $value) { |
| 79 | - $args = [ | |
| 80 | - 'post_type' => 'gvn_schart', | |
| 81 | - 'title' => $value, | |
| 82 | - 'post_status' => 'any', // Adjust if you only want published posts | |
| 83 | - 'numberposts' => 1, | |
| 84 | - ]; | |
| 85 | - | |
| 86 | - $query = new WP_Query($args); | |
| 87 | - $existence = $query->have_posts() ? $query->posts[0] : null; | |
| 88 | - | |
| 89 | - // Clean up after the query | |
| 90 | - wp_reset_postdata(); | |
| 91 | - | |
| 79 | + $existence = get_page_by_title($value, OBJECT, 'gvn_schart'); | |
| 92 | 80 | |
| 93 | 81 | if (empty($existence)) { |
| 94 | 82 | $newid = wp_insert_post(array( |
| 95 | 83 | 'post_title' => $value, |