WordPress 创建自定义主题-可重用性
CMS 和 WordPress 的第一种方法我想知道是否有任何预定义的 html 结构和类/ID“必须是”参考,我可以参考这些参考来使我自己的主题愿意在将来更改为另一个 WordPress 主题,
谢谢
Luca
first approach to CMS and wordpress I'm wondering if there's any predefined html structure and classes/IDs "must-be" reference that I can refer for making my own theme willing to change in the future for another wordpress theme
thanks
Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Wordpress 不要求您的主题中有任何特定的 HTML 和 CSS 类或 ID,WP 唯一需要的是每个页面上元素内的 wp_head 函数。话虽如此,像 Starkers 这样的主题的创建是为了让开发者能够有一个起点,而不是从头开始。
现在,上述内容仅适用于您编写的任何代码,但是 WP 中的某些函数将返回标准代码,例如,如果您没有专门创建评论线程代码,WP 将为你,这实际上是许多主题将共享的唯一代码。
我想说,如果您打算制作多个博客主题,那么拥有一组标准代码可能是一个好主意,例如对于文章页面,这样您就不必重新编写代码以及结束。除此之外,我在制作主题时重复使用的唯一代码是用于设置注释样式的 CSS(如果我不手动编写注释部分),这是一个好主意,因为它将节省您大量时间。
Wordpress doesn't require you to have any specific classes or IDs in your theme in terms of the HTML and CSS, the only things WP needs are things like the wp_head function inside your element on every page. Having said that themes such as Starkers were created to enable developers to have a starting point instead of starting from scratch.
Now the above applies only to whatever code you write, there are however some functions in WP that will return standard code, for instance if you don't specifically create the comment thread code, WP will generate it for you, and that is really the only code that many themes will share.
I would say that if you are intending on making a number of blogging themes for instance, having a set of standard code might be a good idea, for the article pages for example, so that you don't have to re-write code over and over. Aside from that the only code I ever reuse when making themes is the CSS to style comments if I don't hand-code the comments section, this is a good idea as it will save you a lot of time.
Wordpress 提供了一些根据页面类型、模板、条件标签添加 CSS 类的功能。 。 。ETC。
这些函数是
body_class()
和post_class()
。有关详细信息,请检查:
http://codex.wordpress.org/Function_Reference/post_class
http://codex.wordpress.org/Function_Reference/body_class
Wordpress provide some functions which add CSS classes depending of page type, templete, conditional tags . . .etc.
These functions are
body_class()
andpost_class()
.For more info check:
http://codex.wordpress.org/Function_Reference/post_class
http://codex.wordpress.org/Function_Reference/body_class
还有一些其他“模板”主题可以帮助您入门 - 如果 Starkers 不太适合您,您可能会发现 WP Framework是一个不错的选择。或者 - 开始剥离“二十一”主题,为您提供一个基础(这正是 Starkers 主题所做的,使用“二十一”主题作为基础)。
如果您愿意的话,还有关于主题开发的 WordPress Codex 非常方便的首次使用指南从头开始。
There are a few other 'template' themes that could get you started - if Starkers isn't quite your thing, you might find WP Framework a good alternative. Or - just start stripping down the Twenty Eleven theme to give you a base (which is just what the Starkers theme does, using the Twenty Ten theme as a base).
There's also quite a handy first-time guide on the WordPress Codex around theme development if you'd prefer to start from scratch.