$('#myModal').on('shown.bs.modal', function () {
$('#myInput').trigger('focus')
})
if(wc_get_order_status_name() == 'status') {
показать
} else {
Не показать
}
add_filter('template_include', 'my_template');
function my_template( $template ) {
global $post;
if( $post->post_type == 'book' && is_page('portfolio') && is_category( array( 9, 'Без рубрики', 'php') ) ){
if ( $new_template = locate_template( array( 'page-portfolio.php' ) ) )
return $new_template ;
}
return $template;
}
$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 ) );
}
wp_reset_postdata(); // сброс
Добавим страницу настроек
if( function_exists('acf_add_options_page') ) {
$args = array(
'page_title' => 'Параметры',
'menu_title' => '',
'menu_slug' => 'Options',
'post_id' => 'options',
);
acf_add_options_page( $args );
}
echo get_field('phone','options');
// параметры по умолчанию
$args = array(
'numberposts' => 5,
'category' => 0,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'meta_key' => '',
'meta_value' =>'',
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
);
$posts = get_posts( $args );
foreach($posts as $post){ setup_postdata($post);
echo 'Произвольный текст';
echo get_the_title($post-ID);
}
wp_reset_postdata(); // сброс