制作Wordpress主题时要注意什么
我制作 WordPress 主题已经有一两年了,在尝试使我的主题与其设置、插件等尽可能兼容和灵活时,我不断遇到需要记住的事情。
是否有一个资源可以保存清单WordPress 主题的所有“不要忘记”?在构建 WordPress 主题时,您会牢记哪些事项?
示例:
- 检查作者/管理员是否禁用了特定帖子的评论。
- 请记住在
标记末尾调用
wp_head()
。 - 请记住在
标记末尾调用
wp_footer()
。 - 使用
bloginfo()
变量而不是为字符集、html 类型、描述等设置静态值,以便管理员可以在站点设置中修改此类内容。 - 在从插件调用函数之前使用
function_exists()
,这样如果未安装该插件,它就会正常失败。
I have been making Wordpress themes for a year or two and keep running into things I need to keep in mind when trying to make my themes as compatible and flexible as possible with their settings, plugins, etc.
Is there a resource that keeps a checklist of all the "don't forgets" of Wordpress theming? What things do you try to keep in mind when building your Wordpress themes?
Examples:
- Checking if the author/admin has disabled comments for a particular post.
- Remembering to call
wp_head()
at the end of the<head>
tag. - Remembering to call
wp_footer()
at the end of the<body>
tag. - Using
bloginfo()
variables instead of setting static values for charset, html type, description, etc. so admins can modify such things in the site settings. - Using
function_exists()
before calling a function from a plugin so it fails gracefully if that plugin isn't installed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WordPress 文档有一个有趣的主题,正好解决了您的问题:它称为设计公开发布的主题。还有主题开发一般指南。 模板文章也很棒。
我不知道其他官方资源,但在这三个指南中添加更多信息会很有趣。我对您的问题中可能有的其他一些答案感兴趣,以补充它们。
我已经习惯了 Wordpress,以至于您编写的示例在我开发时会自动流动,因为使用输出域信息(例如
bloginfo()
)的函数而不是静态值是一个很好的做法任何网络开发。Wordpress documentation has an interesting topic addressing exactly what you're asking: it's called Designing Themes For Public Release. There's also Theme Development General Guidelines. The Templates article is wonderful too.
I don't know other official resources, but it would be interesting to add more info into those three guides. I'm interested in some other answers we may have in your question to complement them.
I'm so used to Wordpress that the examples you wrote just flows automatically when I'm developing, since using a function that outputs domain information such as
bloginfo()
instead of static values is a good practice in any web development.主题开发清单更多地取决于主题的目标受众。如果它超出了基本博客并转向 WordPress-as-CMS 领域,您需要研究:
A theme development checklist depends more on the intended audience for your theme. If it's beyond the basic blog and moving towards WordPress-as-CMS territory, you'd want to look into:
我们公司还开发了很多各种WordPress和WordPress。 WordPress MU 主题 &我们还没有找到任何“官方”资源,但我们所做的一件事是创建一组基本的模板文件,可以用作“标准”设置,以加快我们的开发过程。
然后,每当需要开发新主题时,我们基本上都会将这组默认模板文件复制/粘贴到 WordPress 安装上的新主题文件夹中。对于我们来说,默认设置中包含的项目是预先填充的 header.php、footer.php、index.php、home.php、single.php、functions.php、comments.php、/images (dir)、 /functions (dir)、style.css、/css (dir)、/scripts (dir) 和一些其他项目。
然后我们还使用 Yahoo Grids 或 Google Blueprint css 框架来加速 css 工作。我还遗漏了一些其他项目/文件,但应该能让您大致了解什么最适合我们商店。
Our firm also develops a lot of various WordPress & WordPress MU themes & we haven't found any "Official" resources, but one thing we've done is create a basic set of template files can can be used as a "standard" setup in order to speed up our development process.
Then, whenever a new theme needs to be developed, we basically copy / paste this default set of template files into a new theme folder on the WordPress install. For us, items we've included in this default setup are pre-populated header.php, footer.php, index.php, home.php, single.php, functions.php, comments.php, /images (dir), /functions (dir), style.css, /css (dir), /scripts (dir), and a handfull of other items.
Then we've also used Yahoo Grids or Google Blueprint css frames works to also speed up the css work. There's a few other items / files I'm leaving out, but should give you a general idea of what works best for us in our shop.