0

i'm using the twentytwelve theme and i have to write custom content into my example template.

I want to maintain my header content so the main structure is the following

header = id page, wrapper

ex.page = primary, content

footer = close wrapper, close id page

If i have understood correctly, if i want to insert content into the middle of my page i have to do it into my template page (that is a copy of the main page.php), that is in the middle between my header and my footer

For example i want to insert a div into which insert the loop of such category.

The problem is that it displays me nothing, like i've wrote nothing. I can only see the contents if i erase all the originary div, but it's not what i want to do, just because the only div is the page which is my container.

I can't catch what i have to do.

Can you tell me what i forgot to do?

Thanks,

Alex

4

2 回答 2

0

page.php 是一个“主”文档。header.php、footer.php 和(如果存在)sidebar.php 都导入到 page.php 中。二十二也使用原子化的内容模板。您可能需要将您的 div 添加到 content-page.php,它也被导入到 page.php 中。content-page.php 在 wordpress 循环中使用,它封装了从 wordpress 数据库中提取实际文章元素的代码。

如果您尝试将直接 HTML 添加到模板中,请确保您没有在 php 括号之间添加代码:

<?php // don't add html here ?>
<div>do add html here</div>

根据您尝试显示的 wordpress 页面的类型,您可能需要查阅Wordpress 模板层次结构以确定模板文件(page.php 的副本)的正确 Wordpress 命名约定。

于 2013-05-20T15:34:41.023 回答
0

从技术上讲,content-page.php 中的所有内容都可以放入 page.php 中,替换 get_template_part 函数。完全不需要所有“内容”页面,如果您想要简单,可以将其合并到一个文件中。

在我看来,学习 Wordpress 时从头开始比尝试重新工作更容易。默认的 wordpress 主题不适合初学者。

于 2013-05-20T23:09:17.690 回答