admin管理员组文章数量:1122846
Trying to solve this issue for the past hour and I can't figure out what's going on.
Trying to create single-blog.php
(I have a few posts which are under the category 'blog') but Wordpress automatically redirects these posts to single.php! I've flushed the permalinks by settings > permalink > save changes but still nothing happens. To test & to see if Wordpress picks up on single-blog.php the code I used was:
<?php get_header(); ?>
<h1>TEST HERE</h1>
<?php get_footer(); ?>
Trying to solve this issue for the past hour and I can't figure out what's going on.
Trying to create single-blog.php
(I have a few posts which are under the category 'blog') but Wordpress automatically redirects these posts to single.php! I've flushed the permalinks by settings > permalink > save changes but still nothing happens. To test & to see if Wordpress picks up on single-blog.php the code I used was:
<?php get_header(); ?>
<h1>TEST HERE</h1>
<?php get_footer(); ?>
Share
Improve this question
edited Oct 1, 2013 at 7:29
Eugene Manuilov
11.4k4 gold badges44 silver badges50 bronze badges
asked Oct 1, 2013 at 7:19
Nazar AbubakerNazar Abubaker
1631 gold badge2 silver badges7 bronze badges
2
|
2 Answers
Reset to default 4Read Template Hierarchy article in the codex, especially pay attention to Single Post Display part.
As you can see you have only three options:
single-{post_type}.php
single.php
index.php
It means that you can't create a template for posts related to blog
category. So you shouldn't use single-blog.php
template, use single.php
instead and add there something like this:
<?php get_header(); ?>
<?php if ( has_category( 'blog' ) : ?>
<h1>TEST HERE</h1>
<?php else : ?>
<h1>Else posts</h1>
<?php endif; ?>
<?php get_footer(); ?>
<?php
if (has_category('blog')) {
include('single-blog.php');
exit;
}
?>
I just need to use this in the single.php file, it's very simple :)
本文标签: postscustom singlephp not working
版权声明:本文标题:posts - custom single.php not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302658a1931615.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Post name - /%postname%/
– Eugine Joseph Commented Oct 6, 2015 at 7:50