изменение шаблона single.php custom-post-template
-
Всем доброго времени суток! Пожалуйста помогите разобраться с проблемой.
Сабж:
Есть примитивный шаблон категории новостей с которого идет переход на страницу single.php с полным текстом поста:
<?php get_header(); ?>
<div id=»container»>
<?php get_sidebar(); ?>
<div id=»content_news»>
<p id =»news»>Новости</p><?php if (have_posts()):?>
<?php while (have_posts()): the_post();?><div class=»post»>
<div class=»p_entry»>
«><?php the_post_thumbnail(); ?>
<div class=»p_head»>
<h1>«><?php the_title(); ?></h1>
</div><!—end p_head—>
<p><?php the_excerpt(); ?>
</p>
» class=»more-link»>Читать далее
<div class=»meta_bottom»>
<span class=»date»><?php the_time(‘j F Y’); ?></span>
</div><!—end meta_bottom—></div><!—end p_entry—>
</div><!—end post—>
<?php endwhile; ?>
<div class=»nav_posts»>
<?php
global $wp_query;$big = 999999999; // need an unlikely integer
echo paginate_links( array(
‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ),
‘format’ => ‘?paged=%#%’,
‘current’ => max( 1, get_query_var(‘paged’) ),
‘total’ => $wp_query->max_num_pages
) );
?></div><!—end nav_posts <?php posts_nav_link(); ?>—>
<?php endif; ?>
</div><!—end content_news—>
</div><!—end container—>
<div class=»clear»></div>
<?php get_footer(); ?>
код страницы single.php:
<?php get_header(); ?>
<div id=»container»>
<?php get_sidebar();?>
<div id=»content_news»>
<p id =»news»>Новости</p><?php if (have_posts()):?>
<?php while (have_posts()): the_post();?><div class=»post»>
<div class=»p_entry»>
<?php the_post_thumbnail(); ?>
<div class=»p_head»>
<h1><?php the_title(); ?></h1>
</div><!—end p_head—>
<p><?php the_content(); ?>
</p><div class=»meta_bottom»>
<span class=»date»><?php the_time(‘j F Y’); ?></span>
</div><!—end meta_bottom—></div><!—end p_entry—>
</div><!—end post—>
<?php endwhile; ?>
<div class=»nav_posts»>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div><!—end nav_posts—><?php endif; ?>
</div><!—end content_news—>
</div><!—end container—>
<div class=»clear»></div>
<?php get_footer(); ?>
этот код работает нормально^
————————————————-В связи с тем, что для другой рубрики мне нужен другой сайдбар и соответственно другая single.php, я установил плагин «custom-post-template»
код другой рубрики (по сути все тоже самое, только выводятся посты другой рубрики и подключен другой сайдбар):
<?php get_header(); ?>
<div id=»container»>
<?php get_sidebar(‘dd’); ?>
<div id=»content_dd»>
<p id =»news»>Дизельная диагностика</p><?php if (have_posts()):?>
<?php while (have_posts()): the_post();?><div class=»post»>
<div class=»p_entry»>
«><?php the_post_thumbnail(); ?>
<div class=»p_head»>
<h1>«><?php the_title(); ?></h1>
</div><!—end p_head—>
<p><?php the_excerpt(); ?>
</p>
» class=»more-link»>Читать далее
<div class=»meta_bottom»>
<span class=»date»><?php the_time(‘j F Y’); ?></span>
</div><!—end meta_bottom—></div><!—end p_entry—>
</div><!—end post—>
Код single2.php:
<?php
/*
Template Name Posts: Diesel diagnostic
*/
?><?php get_header(); ?>
<div id=»container»>
<?php get_sidebar(‘dd’);?>
<div id=»content_dd»>
<p id =»news»>Дизельная диагностика</p><?php if (have_posts()):?>
<?php while (have_posts()): the_post();?><div class=»post»>
<div class=»p_entry»>
<?php the_post_thumbnail(); ?>
<div class=»p_head»>
<h1><?php the_title(); ?></h1>
</div><!—end p_head—>
<p><?php the_content(); ?>
</p><div class=»meta_bottom»>
<span class=»date»><?php the_time(‘j F Y’); ?></span>
</div><!—end meta_bottom—></div><!—end p_entry—>
</div><!—end post—>
<?php endwhile; ?>
<div class=»nav_posts»>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div><!—end nav_posts—><?php endif; ?>
</div><!—end content_news—>
</div><!—end container—>
<div class=»clear»></div>
<?php get_footer(); ?>
Теперь ближе к проблеме… все статьи второй рубрики были отмечены в плагине шаблоном «Diesel diagnostic» для использования single2.php (который отличается от стандартного только сайдбаром):
http://imgur.com/GfiqdxwВ итоге the_permalink который в базовом шаблоне и ведет на single.php работает нормально, выводит базовый сайдбар и полный текст поста без каких либо проблем.
А the_permalink шаблона «Diesel diagnostic» вместо полного текста одного конкретного поста single2.php выводит полный текст всех постов данной рубрики! :(
Пробовал ограничивать выводом 1го поста, при этом ссылки 2й рубрики работают криво!! все тайтл ссылки постов ведут на 1 пост, который является первым в списке.Помогите пожалуйста разобраться. Гуглил, не могу найти решения этой проблемы.
- Форум «изменение шаблона single.php custom-post-template» закрыт для новых ответов.