the_posts_pagination()
работает с глобальным циклом на страницах архивов, используйте для этого paginate_links()
. Можете взять пример отсюда date_default_timezone_set("Europe/Moscow");
$current_time = date('Y-m-d H:i:s');
if ( strtotime($current_time) > strtotime($act_until) ) {
# событие прошло
} else {
# событие НЕ прошло
}
$cities = array(
'mos' => 'Москва',
'spb' => 'Санкт-Петербург',
'nsk' => 'Новосибирск',
'ekb' => 'Екатеринбург',
);
$pathinfo = pathinfo(home_url());
$network_id = get_current_network_id();
$user_id = get_current_user_id();
foreach ( $cities as $key => $city ) {
$site_data = array(
'domain' => $key .'.' . $pathinfo['basename'],
'path' => '/',
'network_id' => $network_id,
'user_id' => $user_id,
'title' => 'Заголовок сайта ' . $city,
'options' => [
'blogdescription' => 'Описание сайта ' . $city,
'permalink_structure' => '/%category%/%postname%/',
'template' => 'twentytwenty',
'stylesheet' => 'twentytwenty',
'posts_per_page' => '12',
'active_plugins' => [
'cyr2lat/cyr-to-lat.php',
'query-monitor/query-monitor.php',
'wordpress-seo/wp-seo.php',
'wp-fastest-cache/wpFastestCache.php'
]
]
);
// вставляем сайт в базу данных
$site_id = wp_insert_site( $site_data );
// пишем ошибку/успех
if( is_wp_error( $site_id ) ) {
var_dump( 'Ошибка инсерта мультисайта ' . $key . ': ' . $site_id->get_error_message() );
} else {
var_dump( 'Мультисайт ' . $key . ' опубликован удачно!' );
}
} // end foreach $cities
if ( is_home() ) {
get_header('home');
} elseif ( is_404() ) {
get_header('404');
} else {
get_header();
}
if ( is_home() ) {
// тут контент уникального хедера домашней страницы
} else {
// тут контент общего хедера для остальных страниц
}
__()
, _e()
, esc_html__()
, esc_html_e()
и подобные<?php echo esc_html__( 'Any text with HTML', 'domain' );
add_action('init', function() {
pll_register_string( 'mytheme', 'Hello world' );
});
pll_e( 'Hello world' );
или получаете для обработки pll__( 'Hello world' );
$carousel_init = "const myCarousel = new Carousel({
container: document.querySelector('.slider'),
items: document.querySelectorAll('.slider__item'),
displayControls: false,
controlsContainer: document.querySelector('.slider__controls'),
autoplay: true,
autoplayTime: 3500
});";
wp_add_inline_script( 'carousel', $carousel_init );
<?php // задаем нужные нам критерии выборки данных из БД
$args = array(
'numberposts' => 4,
'category' => 18,
'post_status' => 'publish',
);
$query = new WP_Query( $args );
// Цикл
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry">
<div class="entry__part entry__header">
<h2 class="entry__title"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="entry__part entry__meta">
<ul class="meta-list meta-list_inline">
<li class="meta-list__item meta-list__item_autor">
<?php echo '<a class="meta-list__link" href="' . get_author_posts_url( get_the_author_meta( 'ID' ) ) . '">' . get_the_author() . '</a>'; ?>
</li>
<li class="meta-list__item meta-list__item_date">
<?php echo '<time class="meta-list__date meta-list__date-published" datetime="' . get_the_date( 'Y-m-d\TH:i:sP' ) . '">' . get_the_date( 'j M, Y' ) . '</time>'; ?>
</li>
<li class="meta-list__item meta-list__item_category">
<?php echo get_the_category_list( ', ' ); ?>
</li>
<li class="meta-list__item meta-list__item_comments-count">
<?php echo '<a class="meta-list__link" href="' . get_comments_link() . '" rel="bookmark">' . __( 'Comments', 'skill' ) . ': ' . get_comments_number() . '</a>'; ?>
</li>
</ul>
</div>
<div class="entry__part entry__excerpt">
<?php the_excerpt(); ?>
</div>
<div class="entry__part entry__link-more">
<a class="link link_more" href="<?php the_permalink() ?>"><?php _e( 'Read more', 'skill' ); ?></a>
</div>
</div>
</article>
<?php }
} else {
// Постов не найдено
}
// Возвращаем оригинальные данные поста. Сбрасываем $post.
wp_reset_postdata();