<?php
$arg_cat = array(
//'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'exclude' => '',
'include' => '',
'taxonomy' => 'pricecat',
);
$categories = get_terms( $arg_cat );
// var_dump( $categories );
?>
<article class="article-post">
<div id="content_box" >
<?php if( $categories ){foreach( $categories as $cat ){
$arg_posts = array(
// 'orderby' => 'name',
'post_type' => 'price',
'post_status' => 'publish',
'posts_per_page' => -1,
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'pricecat',
'field' => 'slug',
'terms' => $cat->slug,
)
),
);
$query = new WP_Query($arg_posts);
?>
<?php if ($query->have_posts() ) ?>
<h2><?php echo $cat->name; ?> </h2>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="main-page-post">
<?php the_title(); ?>
</div>
<?php endwhile?>
<?php
}
}
?>
</div>
</article>
$('a').attr('title', function() {
return $(this).text();
});
document.querySelectorAll('a').forEach(n => n.title = n.innerText);
for (const n of document.getElementsByTagName('a')) {
n.setAttribute('title', n.textContent);
}
function to_prepositional($str) {
if (in_array( substr($str, -1), ['и','о','е','ё','э'])) return $str;
if (in_array( substr($str, -3), ['ово','ево','ино','ыно'])) return $str;
$custom_cities = [
'Москва'=>'Москвы'
];
if (isset($custom_cities[$str])) return $custom_cities[$str];
$replace = array();
$replace['2'][] = array('ия','ии');
$replace['2'][] = array('ия','ии');
$replace['2'][] = array('ий','ом');
$replace['2'][] = array('ое','ом');
$replace['2'][] = array('ая','ой');
$replace['2'][] = array('ль','ле');
$replace['1'][] = array('а','е');
$replace['1'][] = array('о','е');
$replace['1'][] = array('и','ах');
$replace['1'][] = array('ы','ах');
$replace['1'][] = array('ь','и');
foreach ($replace as $length => $replacement) {
$str_length = mb_strlen($str, 'UTF-8');
$find = mb_substr($str, $str_length - $length, $str_length, 'UTF-8');
foreach($replacement as $try) {
if ( $find == $try[0] ) {
$str = mb_substr($str, 0, $str_length - $length, 'UTF-8');
$str .= $try['1'];
return $str;
}
}
}
if ($find == 'е') {
return $str;
} else {
return $str.'е';
}
}
<?php
// Задаем параметры цикла:
$args = array(
'numberposts' => -1,
'post_type' => 'page',
'meta_key' => 'okrug',
'meta_value' => 'ЗАО'
);
// С помощью WP_Query создаем переменную, содержащую все страницы со значением ЗАО в поле округ
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo get_the_post_thumbnail_url(); ?>" />
<?php the_title(); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Возвращаем в норму все глобальные переменные ?>