[英]wordpress page template is not working
我正在研究主题,我想创建页面模板,代码可能如下:
<?php
/*
Template Name: Blog
*/
?>
<?php get_header(); ?>
<div id="content">
<div class="left">
<div class="pagina">
</div>
</div>
</div>
<?php get_footer(); ?>
我已经创建了页面名称Blog,并从下拉Blog中为其分配了自定义模板,但是当我单击导航元素Blog时,它显示了The requested URL /wp/blog/ was not found on this server.
有人可以帮忙吗?
我建议这是一个永久链接问题,而不是模板问题。 您的.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
那可能是许多原因之一; 您拥有博客模板,或者可能是因为您没有包含循环:
<?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(); ?>
如果仍然无法解决问题,请尝试刷新您的永久链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.