correct number tags
This commit is contained in:
89
single-3.php
89
single-3.php
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
// Включить отображение всех типов ошибок
|
||||
//ini_set('display_errors', 1);
|
||||
//ini_set('display_startup_errors', 1);
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
require TEMPLATEPATH.'/helpers/number_title.php';
|
||||
|
||||
get_header();?>
|
||||
@@ -61,46 +68,54 @@ get_header();?>
|
||||
$pitems = [];
|
||||
$endpolosa = 1;
|
||||
|
||||
foreach ($posts as $post){
|
||||
|
||||
$posttags = get_the_tags($post->ID);
|
||||
|
||||
foreach ($posttags as $tag){
|
||||
$pfind = strpos($tag->name, 'полоса');
|
||||
if ($pfind !== false) {
|
||||
$number = substr($tag->name, 0, $pfind);
|
||||
if ($number > $endpolosa ){
|
||||
$endpolosa = $number;
|
||||
}
|
||||
$pitems[$number][] = $post;
|
||||
}
|
||||
}
|
||||
}?>
|
||||
if ( !empty($posts) ) {
|
||||
|
||||
<?for ($i = 1; $i <= $endpolosa; $i++) {?>
|
||||
<?if (isset($pitems[$i])):?>
|
||||
<!--<h2 class="part_title">Полоса <?=$i?></h2>-->
|
||||
<?foreach($pitems[$i] as $item):?>
|
||||
<?$category = get_the_category($item->ID);
|
||||
$category_id = $category[0]->term_id;
|
||||
$category_link = get_category_link($category_id);?>
|
||||
foreach ($posts as $post){
|
||||
|
||||
$posttags = get_the_tags($post->ID);
|
||||
|
||||
<div class="main-card">
|
||||
<?if ( has_post_thumbnail($item->ID) ) :?>
|
||||
<div class="polosa-img">
|
||||
<a href="<?the_permalink($item->ID);?>"><img src="<?php echo get_the_post_thumbnail_url($item->ID, 'large'); ?>" alt="<?=$item->title;?>"></a>
|
||||
foreach ($posttags as $tag){
|
||||
$pfind = strpos($tag->name, 'полоса');
|
||||
|
||||
if ($pfind !== false) {
|
||||
|
||||
$number = (int)substr($tag->name, 0, $pfind);
|
||||
|
||||
if ($number > $endpolosa ){
|
||||
$endpolosa = $number;
|
||||
}
|
||||
$pitems[$number][] = $post;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?for ($i = 1; $i <= $endpolosa; $i++) {?>
|
||||
<?if (isset($pitems[$i])):?>
|
||||
<!--<h2 class="part_title">Полоса <?=$i?></h2>-->
|
||||
<?foreach($pitems[$i] as $item):?>
|
||||
<?$category = get_the_category($item->ID);
|
||||
$category_id = $category[0]->term_id;
|
||||
$category_link = get_category_link($category_id);?>
|
||||
|
||||
<div class="main-card">
|
||||
<?if ( has_post_thumbnail($item->ID) ) :?>
|
||||
<div class="polosa-img">
|
||||
<a href="<?the_permalink($item->ID);?>"><img src="<?php echo get_the_post_thumbnail_url($item->ID, 'large'); ?>" alt="<?=$item->title;?>"></a>
|
||||
</div>
|
||||
<?endif?><br>
|
||||
<div class="main-card-title"><p><a href="<?the_permalink($item->ID);?>"><?=get_the_title($item->ID);?></a></p></div>
|
||||
<div class="main-card-body">
|
||||
<div><a href="<?the_permalink($item->ID);?>"><?=$item->post_excerpt?></a></div><br>
|
||||
<div class="news_date"><a href="<?=$category_link?>"><?=$category['0']->name?></a></div>
|
||||
</div>
|
||||
<?endif?><br>
|
||||
<div class="main-card-title"><p><a href="<?the_permalink($item->ID);?>"><?=get_the_title($item->ID);?></a></p></div>
|
||||
<div class="main-card-body">
|
||||
<div><a href="<?the_permalink($item->ID);?>"><?=$item->post_excerpt?></a></div><br>
|
||||
<div class="news_date"><a href="<?=$category_link?>"><?=$category['0']->name?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?endforeach?>
|
||||
<?endif?>
|
||||
<?}?>
|
||||
</div>
|
||||
<?endforeach?>
|
||||
<?endif?>
|
||||
<?}
|
||||
}?>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user