wp_enqueue_script()
третьим параметром передадите зависимость от скрипта jquery, то сначала подключится он, после него ваш скриптis_paged()
add_action( 'pre_get_posts', 'limit_posts_per_home_page', 1 );
function limit_posts_per_home_page( $query ) {
if ( $query->is_category( 6 ) && !$query->is_paged() ) {
$query->set( 'posts_per_page', 6 );
}
}
wp_enqueue_style()
add_action( 'wp_enqueue_scripts', 'wpz_scripts' );
function wpz_scripts() {
// Bootstrap стили
wp_enqueue_style( 'bootstrap-styles', get_theme_file_uri( 'css/bootstrap.min.css' ) , array(), filemtime( get_theme_file_path( '/css/bootstrap.min.css' ) ) );
// Основные стили
wp_enqueue_style( 'common-styles', get_theme_file_uri( 'css/style.min.css' ) , array( 'bootstrap-styles' ), filemtime( get_theme_file_path( '/css/style.min.css' ) ) );
}
get_template_directory_uri()
<a href="#"><img src="<?php echo get_template_directory_uri(); ?>/img/facebook.png" alt=""></a>
<a href="#" class="p-2"><img src="<?php echo get_template_directory_uri(); ?>/img/instagram.png" alt=""></a>
get_users()
и посмотреть какие аргументы она принимаетget_terms()
$terms = get_terms( [
'taxonomy' => 'genres',
'hide_empty' => false,
] );
if ( $terms ) {
echo '<ul class="genres-list">';
foreach ( $terms as $key => $term ) {
echo '<li><a href="' . get_term_link( $term->term_id, $term->taxonomy ) . '">' . $term->name . '</a></li>';
}
echo '</ul>';
}
if ( is_post_type_archive( 'book' ) ) {
// ...
}
$year = 2008;
$current_year = date( 'Y' );
echo '<ul>';
while ( $year <= $current_year ) {
echo '<li><a href="' . get_year_link( $year ) . '">' . $year . '</a></li>';
$year++;
}
echo '</ul>';
$year = 2008;
$current_year = date( 'Y' );
echo '<ul>';
while ( $year <= $current_year ) {
$args = array(
'year' => $year,
'post_status' => 'publish, future, draft, pending',
'posts_per_page' => 1,
'fields' => 'ids'
);
$posts = get_posts( $args );
if ( is_array( $posts ) && !empty( $posts ) ) {
echo '<li><a href="' . get_year_link( $year ) . '">' . $year . '</a></li>';
}
$year++;
}
echo '</ul>';
$args = array(
'posts_per_page' => 1,
'order' => 'ASC'
);
$posts = get_posts( $args );
if ( $posts ) {
$year = date( 'Y', strtotime( $posts[0]->post_date ) );
}
$ani = '25';
echo '<span class="advantage__text-green">' . $ani . ' ' . pll__( 'ani' ) . '</span>' . pll__( 'experiență pe piață' );
_n()
и _x()
, производной _nx()
, а так же базовых __()
и esc_html__()
the_field()
. Вторым параметром она принимает $post_id, это глобальная переменная текущего поста в цикле должна быть установленаvar_dump( get_field( 'header-descr-strong' ) );
serialize()
$array = [
'group_price' => '3.6',
'group_price_type' => 'fix',
];
echo serialize( $array );
json_decode()
и json_encode()
global $authordata;
// проверяем, что находимся в своем личном кабинете и имеем роль subscriber
if ( is_author() && is_user_logged_in() && is_object( $authordata ) && in_array( 'subscriber', $authordata->roles ) && $authordata->data->ID == get_current_user_id() ) {
}