Wordpress 未将模板应用于博客页面
Wordpress not applying template to blog page
我不知道我做错了什么...我已经为我的博客构建了一个主题,当我构建它时,它可以在我的本地服务器上运行(使用 mamp)。从那时起,我将我的网站移到了网上,但现在博客的模板没有应用到博客页面。 Here is the blog. I have checked in the admin where it points to that template file. It is indeed pointing to the correct file, but it's just not getting applied. I also tried the advice given in this question: Applying templates to pages loaded from Wordpress Loop 并开启了 wp_debug。它没有 return 给我任何错误。我真的迷失了。下面是模板文件中的代码。如果您查看我博客的源代码,您会发现它们不匹配,因为未应用此模板文件。有人知道是什么导致应用了模板吗?
模板文件中的代码:
<?php
/*
Template Name: Blog Template
*/
get_header();
?>
<span>Is this thing on?</span>
<div id="blog_content">
<?php
query_posts('post_type=post');
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<div class="blog_post">
<div class="post_wrap">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="entry_date"><?php the_time('F jS, Y') ?></div>
<?php
the_content();
?>
<div class ="post_foot">
<div class="comment_links">
<a href="<?php the_permalink(); ?>">View Comments / Leave a Comment</a>
</div>
<div class="social_shares">
Share this article with your frenz!
<ul class="share_links">
<li><a class="fb_share_link" target="_blank" href="http://www.facebook.com/sharer.php?u=<?php esc_url(the_permalink());?>"></a></li>
<li><a class="twitter_share_link" target="_blank" href="#"></a></li>
<li><a class="google_share_link" target="_blank" href="#"></a></li>
<li><a class="reddit_share_link" target="_blank" href="#"></a></li>
<li><a class="pin_share_link" target="_blank" href="#"></a></li>
<li><a class="linkedin_share_link" target="_blank" href="#"></a></li>
<li><a class="mail_share_link" target="_blank" href="#"></a></li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<?php
}
}
?>
<div class="nav-previous alignleft"><?php next_posts_link('Older posts'); ?></div>
<div class="nav-next alignright"><?php previous_posts_link('Newer posts'); ?></div>
</div>
<div id="blog_sidebar">
<div class="sidebar_block">
<div class="sidebar_wrap">
<?php get_sidebar(); ?>
</div>
</div>
<div class="sidebar_block">
<div class="sidebar_wrap">
Hello! This is a test to make sure adding another block here won't hurt anything but let's be honest it probably will break the internet.
</div>
</div>
</div>
好的刚刚找到解决方案。
原来我所要做的就是进入管理面板,然后进入
settings > reading
并将帖子页面更改为“-Select-”,然后它立即开始从我的模板文件中读取。我发现愚蠢的 WordPress 有一些愚蠢的层次结构系统,如果你告诉它哪个页面是帖子页面,它会拉出一个不同的模板文件。 (哪个文件?我不知道
如果你问我真的很愚蠢,考虑到我只花了大约 5 个小时来解决这个问题而且没有人在这个问题上与我互动所以我想我会留下它以防其他人有同样的问题问题。
我不知道我做错了什么...我已经为我的博客构建了一个主题,当我构建它时,它可以在我的本地服务器上运行(使用 mamp)。从那时起,我将我的网站移到了网上,但现在博客的模板没有应用到博客页面。 Here is the blog. I have checked in the admin where it points to that template file. It is indeed pointing to the correct file, but it's just not getting applied. I also tried the advice given in this question: Applying templates to pages loaded from Wordpress Loop 并开启了 wp_debug。它没有 return 给我任何错误。我真的迷失了。下面是模板文件中的代码。如果您查看我博客的源代码,您会发现它们不匹配,因为未应用此模板文件。有人知道是什么导致应用了模板吗?
模板文件中的代码:
<?php
/*
Template Name: Blog Template
*/
get_header();
?>
<span>Is this thing on?</span>
<div id="blog_content">
<?php
query_posts('post_type=post');
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<div class="blog_post">
<div class="post_wrap">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="entry_date"><?php the_time('F jS, Y') ?></div>
<?php
the_content();
?>
<div class ="post_foot">
<div class="comment_links">
<a href="<?php the_permalink(); ?>">View Comments / Leave a Comment</a>
</div>
<div class="social_shares">
Share this article with your frenz!
<ul class="share_links">
<li><a class="fb_share_link" target="_blank" href="http://www.facebook.com/sharer.php?u=<?php esc_url(the_permalink());?>"></a></li>
<li><a class="twitter_share_link" target="_blank" href="#"></a></li>
<li><a class="google_share_link" target="_blank" href="#"></a></li>
<li><a class="reddit_share_link" target="_blank" href="#"></a></li>
<li><a class="pin_share_link" target="_blank" href="#"></a></li>
<li><a class="linkedin_share_link" target="_blank" href="#"></a></li>
<li><a class="mail_share_link" target="_blank" href="#"></a></li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<?php
}
}
?>
<div class="nav-previous alignleft"><?php next_posts_link('Older posts'); ?></div>
<div class="nav-next alignright"><?php previous_posts_link('Newer posts'); ?></div>
</div>
<div id="blog_sidebar">
<div class="sidebar_block">
<div class="sidebar_wrap">
<?php get_sidebar(); ?>
</div>
</div>
<div class="sidebar_block">
<div class="sidebar_wrap">
Hello! This is a test to make sure adding another block here won't hurt anything but let's be honest it probably will break the internet.
</div>
</div>
</div>
好的刚刚找到解决方案。
原来我所要做的就是进入管理面板,然后进入
settings > reading
并将帖子页面更改为“-Select-”,然后它立即开始从我的模板文件中读取。我发现愚蠢的 WordPress 有一些愚蠢的层次结构系统,如果你告诉它哪个页面是帖子页面,它会拉出一个不同的模板文件。 (哪个文件?我不知道
如果你问我真的很愚蠢,考虑到我只花了大约 5 个小时来解决这个问题而且没有人在这个问题上与我互动所以我想我会留下它以防其他人有同样的问题问题。