$posts = get_posts( array(
'numberposts' => - 1,
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) );
foreach ( $posts as $post ) {
setup_postdata( $post );
if ( strpos( $post->name, 'trololo' ) ) {
$i ++;
$new_name = $post->name . '-' . $i;
// Создаем массив данных
$my_post = array();
$my_post['ID'] = $post->ID;
$my_post['post_name'] = $new_name;
}
// Обновляем данные в БД
wp_update_post( wp_slash( $my_post ) );
//Для наглядности выведем отчет
echo 'Обновил '.$post->id.' <br /> Его post_name: '.$post->name.' <br /> Его title: '.$post->title.'<hr />';
}
wp_reset_postdata(); // сброс
echo get_the_title($post->ID)
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );
function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
$my_attr = 'course-name'; //<---- ИД ВАШЕГО ПОЛЯ
if ( isset( $atts[$my_attr] ) ) {
$out[$my_attr] = $atts[$my_attr];
}
return $out;
}