WordPress模板问题
我设置了一个模板,我的默认模板是 2 列,我有一个页面想要 1 列。我怎样才能在wordpress中做到这一点?它是functions.php的代码吗?
请提前提出建议并致谢。
I set a template and my default template is 2 columns and i have a page that i want to have a 1 column. How can I make that in wordpress? is it a code for the functions.php?
Please suggest and thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有不同的选项,您可以选择您喜欢的一个:)
如果您的主题已经支持单栏页面,您应该在编辑页面屏幕的右侧有一个“页面属性”框,其中包含一个名为“模板”,当您可以选择不同的模板时(在默认的 WordPress 主题“TwentyTen”中,它被称为“一栏,无侧边栏”)。
如果您的主题不支持单栏页面,您可以自己创建自定义页面模板:
* 模板名称:您想要的模板名称
如果您不喜欢“新模板+选择框”的方式,您可以直接在“page.php”上添加“IF”,以在需要时注释掉 get_sidebar(),基于 $post-> ;ID 或类似的检查。
之后,您可能必须编辑 .css(调整宽度)和 new-page.php(例如向 div 容器添加“一列”类)以适应尺寸。
You have different options and you could choose the one you prefer :)
If your theme already supports a one-column page you should have on the right side of your edit page screen a box "Page attributes" with a select box named "Templates" when you could choose a different template (in default Wordpress theme "TwentyTen" is it called "One column, no sidebar").
If your theme doesn't support a one-column page you could create a custom page template by yourself:
* Template Name: The name you want for your template
<?php get_sidebar(); ?>
If you don't like the "new template + select box" way you could directly add a "IF" on your "page.php" to comment-out the get_sidebar() when needed, based on $post->ID or similar checks.
After this probably you'll have to edit your .css (adjusting width) and new-page.php (like adding a class "one-column" to the div container) to fit the dimensions.
转到您想要单列的页面的编辑页面区域。在模板下(在右侧栏中)查找“单列”或“全宽”页面。
90%的主题都有这个。如果你的没有,你就必须下载 page.php。复制它并将其重命名为 fullwidth-page.php 并重新上传。根据 wordpress.org 中的“页面模板代码”,确保顶部的评论区域正确。然后,删除调用 sidebar() 代码的地方。在主要内容区域添加更多的内联 CSS,使内联样式宽度成为完整宽度。
Go to the edit page area of the page you want to have single column. Under templates (in the right hand side bar) look for "single column" or "full width" page.
90% of themes have this. If yours does not, you would have to take page.php, download it. Duplicate it and rename it to fullwidth-page.php and reupload. Make sure the comment area at the top is right according to the "page template codex" in wordpress.org. Then, delete out wehre it calls the sidebar() code. Add a bit more inline CSS to the main content area to make the inline style width the full width then.