0

我正在研究主题,我想创建页面模板可能代码如下:

<?php
/*
Template Name: Blog
*/
?>

<?php get_header(); ?>

<div id="content">

<div class="left">

<div class="pagina">

</div>

</div>
</div>

<?php get_footer(); ?>

我创建了页面名称博客并从下拉博客中为其分配了一个自定义模板,但是当我单击导航元素博客时它显示The requested URL /wp/blog/ was not found on this server.

有人可以帮忙吗?

4

2 回答 2

3

我建议这是一个永久链接问题,而不是模板问题。您的 .htaccess 文件应该是可写的,并且您应该在设置永久链接时自动添加一些代码。检查它是否可写并尝试再次设置永久链接。如果做不到这一点,我相信 WordPress 会在您设置永久链接时为您提供复制/粘贴到其中的代码。

简而言之,将此代码添加到您的 .htaccess 文件中,如果它还没有的话。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
于 2013-11-13T14:10:17.397 回答
2

这可能是众多原因之一;要么你有一个博客模板,要么可能是因为你没有包含循环:

<?php
/*
Template Name: Archives with Content
*/
?>

<?php get_header(); ?>

<div id="content" class="">
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <div class="left">
        <h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
        <div class="entrytext">
            <?php the_content(); ?>
        </div>
    </div>
    <?php endwhile; endif; ?>
</div>

<div id="main">
    <?php get_search_form(); ?>
    <!-- and whatever else you need -->
</div>
<?php get_footer(); ?>

如果这仍然不起作用,请尝试刷新您的永久链接

于 2013-11-13T14:14:36.693 回答