// добавляем дополнительный текст в контент
add_filter( 'the_content', 'add_custom_text_to_content' );
function add_custom_text_to_content( $content ) {
$before = '<p>Custom text before content</p>';
$after = '<p>Custom text after content</p>';
return $before . $content . $after;
}
if ( in_category('fruit') ) {
get_template_part( 'templates/single', 'fruit' );
} elseif ( in_category('vegetables') ) {
get_template_part( 'templates/single', 'vegetables' );
} else {
get_template_part( 'templates/single', 'common' );
}
<a href="#">
, а вы не можете его вставить в тег <option>
напрямую$tags = get_terms( [
'taxonomy' => 'post_tag',
'hide_empty' => false,
] );
if ( $tags ) {
echo '<ul class="tag-list">';
foreach ( $tags as $key => $tag ) {
echo '<li class="tag-list__item"><a class="tag-list__link" href="' . esc_url( get_term_link( $tag->term_id ) ) . '">' . esc_html( $tag->name ) . '</a></li>';
}
echo '</ul>';
}
if ( is_front_page() && is_user_logged_in() ) {
echo 'Вы авторизованы на сайте';
} else {
echo 'Вы НЕ авторизованы на сайте';
}
add_action( 'template_redirect', function() {
if( is_front_page() && !is_user_logged_in() ) {
wp_redirect( 'http://example.org/path/to/subscribe', 301 );
exit;
}
} );
$args = [
'theme_location' => 'aside-1',
'menu' => '',
'container' => '',
'container_class' => '',
'container_id' => '',
'menu_class' => 'aside-menu__inner',
'menu_id' => '',
'echo' => true,
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul id="%1$s" class="%2$s dflex">%3$s</ul>',
'depth' => 1,
];
if ( get_field('name_direction_2') ) {
$args['menu'] = get_field('name_direction_2');
}
wp_nav_menu( $args );
add_action( 'wp_enqueue_scripts', 'include_custom_scripts' );
function include_custom_scripts() {
wp_enqueue_script( 'basket', get_stylesheet_directory_uri() . '/js/basket.min.js', array('jquery'), null, true );
wp_enqueue_script( 'main', get_stylesheet_directory_uri() . '/js/main.min.js', array('jquery'), null, true );
}
get_theme_file_uri()
, которая проверяет наличие файла в дочерней теме, это довольно удобноfilemtime()
add_action( 'wp_enqueue_scripts', 'include_custom_scripts' );
function include_custom_scripts() {
wp_enqueue_script( 'basket', get_theme_file_uri( '/js/basket.min.js' ), array('jquery'), filemtime( get_theme_file_path( '/js/basket.min.js' ) ), true );
wp_enqueue_script( 'main', get_theme_file_uri( '/js/main.min.js' ), array('jquery'), filemtime( get_theme_file_path( '/js/main.min.js' ) ), true );
}