【问题标题】:Wordpress not applying template to blog pageWordpress 未将模板应用于博客页面
【发布时间】:2015-03-13 03:05:10
【问题描述】:

我不知道我做错了什么...我已经为我的博客构建了一个主题,当我在此基础上构建时,它可以在我的本地服务器上运行(使用 mamp)。从那以后,我将我的网站移到了网上,但现在博客的模板没有应用到博客页面。 Here is the blog。我已经签入了指向该模板文件的管理员。它确实指向正确的文件,但它只是没有得到应用。我还尝试了这个问题中给出的建议:Applying templates to pages loaded from Wordpress Loop 并打开了 wp_debug。它没有向我返回任何错误。我真的迷路了。下面是模板文件中的代码。如果您查看我博客的源代码,您会看到它们不匹配,因为没有应用此模板文件。有谁知道是什么导致模板被应用?

模板文件中的代码:

<?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>

【问题讨论】:

  • 更新:不管我在后台修改什么模板文件,都没有改变!

标签: html wordpress templates wordpress-theming


【解决方案1】:

好的,刚刚找到解决方案。

原来我所要做的就是进入管理面板,然后转到

设置>阅读

并将帖子页面更改为“-Select-”,然后它立即开始从我的模板文件中读取。我发现愚蠢的 WordPress 有一些愚蠢的层次结构系统,如果你告诉它哪个页面是帖子页面,它会拉取不同的模板文件。 (哪个文件?我不知道

如果你问我真的很愚蠢,考虑到我只花了大约 5 个小时来解决这个问题,而且没有人让我参与这个问题,所以我想我会留下它,以防其他人遇到同样的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-10
    • 1970-01-01
    相关资源
    最近更新 更多