// добавить в functions.php
/**
* Получение термина верхнего уровня
*
* @param $term_id int ID термина
* @param $taxonomy string таксономия
*
* @return array|int|null|WP_Error|WP_Term
*/
function wpp_get_term_top_level_id( $term_id, $taxonomy ) {
$term_parent = 0;
while ( $term_id ) {
$term = get_term( $term_id, $taxonomy );
$term_id = $term->parent;
$term_parent = $term;
}
return $term_parent;
}// Start the loop.
while ( have_posts() ) : the_post();
$terms = get_the_terms( get_the_ID(), 'БББ' );
if(!empty($terms)) {
$need_term = wpp_get_term_top_level_id( $terms[0]->term_id, 'БББ' );
get_template_part( 'taxonomy/content-taxonomy/content-taxonomy', $need_term->slug);
} else {
echo 'не установлены термины таксономии БББ';
} $results_rating = $wpdb->get_col("SELECT * FROM $table_name");[10,11,12,13,14,15]$post_id= $rowes->id;foreach ($results_rating as $rowes) $post_id = $rowes$post_id= end($results_rating) <?php
/**
* Template Name: Бла бла бла
*/
get_header();
$args = [
'post_type' => 'product',
'tax_query' => [
[
'taxonomy' => 'product_cat',
'field' => 'name',
'terms' => 'Tem Name',
],
],
'posts_per_page' => - 1,
];
global $wp_query;
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) :
woocommerce_product_loop_start();
?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile;
woocommerce_product_loop_end();
?>
<?php else : ?>
<div>Товаров не найдено</div>
<?php endif;
get_footer(); Get a value from a specific post
This example shows how to load the value of field ‘text_field’ from the post with ID = 123.
$value = get_field( "text_field", 123 );
function my_shortcode_function() {
$wp_query = new WP_Query( [
'post_type' => 'portfolio',
'posts_per_page' => 6,
'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1
] );
ob_start();
echo '<div class="portfolio">';
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
get_template_part( 'template-parts/portfolio', get_post_format() );
endwhile;
else :
get_template_part( 'template-parts/content', 'none' );
endif;
echo '</div>';
posts_nav_link();
$out = ob_get_clean();
return $out;
}То есть у меня на странице 'site.com/portfolio' есть шесть записей, по клику на кнопку "Следующая страница →" я перехожу на страницу 'site.com/portfolio/page/2/' - но это страница 404..как исправить проблему?