function shownews(){
ob_start();
?>
<div class="swiper-container">
<div class="swiper-wrapper">
<?php
$query = new WP_Query( array( 'cat' => 5, 'showposts' => 100 ) );
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="service__slide" id="bx_651765591_37">
<?php $image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); ?>
<a href="" class="card-service card-service--family" style="background-image:url(<?php echo $image_url[0]; ?>);">
<div class="card-service__title"><?php the_title(); ?></div>
<span class="card-service__link"><?php the_content(); ?></span>
</a>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
</div>
<?php
return ob_get_clean();
}
add_shortcode('shortshownews', 'shownews');
// rewrites custom post type name
global $wp_rewrite;
$news_structure = '%postname%/%year%/%monthnum%/%day%/';
$wp_rewrite->add_permastruct('news', $news_structure, false);
add_filter( 'intermediate_image_sizes_advanced', 'prefix_remove_default_images' );
// Remove default image sizes here.
function prefix_remove_default_images( $sizes ) {
unset( $sizes['small']); // 150px
//unset( $sizes['medium']); // 300px
unset( $sizes['large']); // 1024px
unset( $sizes['medium_large']); // 768px
return $sizes;
}
$posts = get_posts(array(
'post_type' => 'your_post_type',
'meta_query' => array(
array(
'key' => 'solution', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
));
function atrs() {
global $product;
$atrs = get_the_terms($product->get_id(), 'pa_atr');
foreach ($atrs as $atr) {
$icon = get_field('classicon', 'term_' .$atr->term_id);
echo '<a target="_blank" href="' . get_site_url() . '/shop/?pa_atr=' . $atr->slug . '">'. $atr->name . ' </a>';
echo '<i class="fa fa-"' . $icon . '></i>';
}
}
$taxonomy_info = wp_get_post_terms(get_the_ID(), 'your_taxonomy')[0];
$current_id = get_the_ID();
$args = array(
'post_type' => 'post',
'posts_per_page'=> 8,
'tax_query'=> array(
array(
'taxonomy'=> $taxonomy_info->taxonomy,
'field'=> 'id',
'terms'=>$taxonomy_info->term_id
)
),
'post__not_in' => array($current_id),
'orderby' => 'rand'
);
$wp_query = new WP_Query($args);
if ($wp_query->have_posts()) {
while ($wp_query->have_posts()) {
$wp_query->the_post();
//....code...
}
}
Надеюсь вы понимаете, что вместо "your_taxonomy" должна быть ваша таксономия, тоже можно сказать про post_type или posts_per_page