/wp-content/themes/ПАПКА_ТЕМЫ/images/image.jpg
add_action( 'wp_enqueue_scripts', 'action_function_name_7714', 99 );
function action_function_name_7714(){
wp_localize_script( 'jquery', 'mytheme', array(
'template_url' => get_template_directory_uri(),
) );
}
mytheme.template_url + '/images/image.jpg'
$args = array('post_type' => 'product', 'product_cat' => 'accessories', 'test1' => $product_tag );
$args = array('post_type' => 'product', 'meta_key' => 'test1', 'meta_value' => $product_tag );
home.php
, page.php
— это для "просто страниц".<?php
$custom_query = new WP_Query( $args );
if ( $custom_query->have_posts() ) {
while ( $custom_query->have_posts() ) {
$custom_query->the_post();
?>
<div>News</div>
<?php
}
if ( $custom_query->max_num_pages > 1 ) {
$orig_query = $wp_query;
$wp_query = $custom_query;
the_posts_pagination( array(
'show_all' => true
) );
$wp_query = $orig_query;
}
wp_reset_postdata();
} else {
echo 'Ничего не найдено';
}
?>
function category_shop_func( $atts ) {
$output = '<div class="category_shop">';
$params = shortcode_atts( array( // в массиве укажите значения параметров по умолчанию
'category_id' => '', // параметр 1
), $atts );
$args = array(
'taxonomy' => 'product_cat',
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids,
'child_of' => $params['category_id']
);
$product_categories = get_terms( $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
$item = '<div class="catalog__category category-block">';
$item .= '<a href="' . get_term_link( $product_category ) . '" class="category-block__link">Перейти</a>';
$item .= '<img class="category-block__img" src="'. wp_get_attachment_url( $thumbnail_ids ) .'" alt="">';
$item .= '<h3 class="category-block__title">' . $product_category->name . '</h3>';
$item .= '</div>';
$output .= $item;
}
}
$output .= '</div>';
return $output;
}
add_shortcode( 'category_shop', 'category_shop_func' );
$ngp_post_array = array_map( 'sanitize_text_field', wp_unslash( $_POST['ngp_rules'] ) );
if( isset( $_GET['utm_source'] ) && $_GET['utm_source'] == 'google' ) {
setcookie( 'from_adv', 1, time() + 365 * 24 * 60 * 60, '/' );
}
if( isset( $_COOKIE['from_adv'] ) && $_COOKIE['from_adv'] ) {
//Телефон 555
} else {
//Телефон 777
}
'has_archive' => 'models'
'has_archive' => true,
'rewrite' => array('slug' => 'models'),
<?php
$categories = get_categories(array(
'orderby' => 'name',
'order' => 'ASC'
));
foreach( $categories as $category ){
echo '<a href="' . get_category_link( $category->term_id ) . '" class="category-box"> ';
echo '<div class="category-box-content"><h3>' . $category->name . '</h3></div></a>';
echo '<p>' . the_field('icon', 'category_' . $category->term_id) . '</p>';
}
?>
Плагины не интерисуют
function my_document_title_parts( $title ) {
if ( is_category() ) {
unset( $title['site'] );
}
return $title;
}
add_filter( 'document_title_parts', 'my_document_title_parts' );