简体   繁体   English

Wordpress页面模板不起作用

[英]wordpress page template is not working

I am working on theme and i want to create page template may code is below : 我正在研究主题,我想创建页面模板,代码可能如下:

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

<?php get_header(); ?>

<div id="content">

<div class="left">

<div class="pagina">

</div>

</div>
</div>

<?php get_footer(); ?>

I have creat page name Blog and assign it a custom template from dropdown Blog,But when I click on navigation element Blog it shows The requested URL /wp/blog/ was not found on this server. 我已经创建了页面名称Blog,并从下拉Blog中为其分配了自定义模板,但是当我单击导航元素Blog时,它显示了The requested URL /wp/blog/ was not found on this server.

anyone can help? 有人可以帮忙吗?

I'd suggest this is a permalink issue, not a template issue. 我建议这是一个永久链接问题,而不是模板问题。 Your .htaccess file should be writable and you should have some code automatically added to it when you set up the permalinks. 您的.htaccess文件应为可写文件,并且在设置永久链接时应自动向其中添加一些代码。 Check that it is writable and try setting the permalinks up again. 检查它是否可写,然后尝试重新设置永久链接。 Failing that, I believe that WordPress gives you the code to copy/paste into it when you're setting up the permalinks. 失败的话,我相信WordPress在设置永久链接时会为您提供复制/粘贴到其中的代码。

In short, add this code to your .htaccess file, if it's not there already. 简而言之,将此代码添加到您的.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

That could be one of many reasons; 那可能是许多原因之一; either you have a blog template or it could be because you have not included the loop: 您拥有博客模板,或者可能是因为您没有包含循环:

<?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(); ?>

If that still does not work, try refreshing your permalinks 如果仍然无法解决问题,请尝试刷新您的永久链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM