对于新朋友而言,WordPress中的文章类型是令人迷糊的。
对于开发者来说,WordPress中的“文章”和面向对象编程中的“类”有点像。WordPress 中所有的文章都存储在 wp_posts 数据表中。wp_posts 有一个字段:post_type,文章类型说的就是这个字段。
post_type 默认的合规值有:
1. Post (Post Type: ‘post’)
2. Page (Post Type: ‘page’)
3. Attachment (Post Type: ‘attachment’)
4. Revision (Post Type: ‘revision’)
5. Navigation menu (Post Type: ‘nav_menu_item’)
6. Block templates (Post Type: ‘wp_template’)
7. Template parts (Post Type: ‘wp_template_part’)
除此之外,还有开发者自己注册的文章类型(使用 register_post_type 函数)。
对于建站者来说,“文章”一般特指特指 post_type 为 post 的文章。
搞清楚自己的角色是开发者还是建站者,就不会对 WordPress 中的文章迷糊了。
WordPress主题中对各种文章类型都有充分的支持。
文章类型 post 相关的模板文件包括:single.php、category.php、tag.php、taxonomy.php、archive.php、author.php、date.php、search.php、home.php、index.php 等。
文章类型 page 相关的模板文件包括:page.php、front-page.php、search.php、index.php 等。
文章类型 attachment 相关的模板文件包括:mimetype.php、attachment.php、single-attachment.php、single.php、index.php 等。
自定义文章类型的相关模板包括:single-{post-type}.php、archive-{post-type}.php、search.php、index.php 等。
对于 revision、nav_menu_item、wp_template、wp_template_part 四种类型,有点因为其不必展示,或是页面的一部分,而没有相对应的模板文件。
-
WordPress函数:wp_enqueue_code_editor 引入代码编辑器需要的js和cssWordPress函数:wp_enqueue_code_editor 引入代码编辑器需要的js和css
-
WordPress函数:wp_enqueue_block_style 为特定块引入样式表WordPress函数:wp_enqueue_block_style 为特定块引入样式表
-
WordPress函数:wp_enqueue_global_styles 引入theme.json定义的全局样式WordPress函数:wp_enqueue_global_styles 引入theme.json定义的全局样式
-
WordPress函数:wp_enqueue_stored_styles 处理核心样式合并到页面中WordPress函数:wp_enqueue_stored_styles 处理核心样式合并到页面中
-
WordPress教程菜鸟教程之WordPress主题和插件开发追格小编同学已经撰写并分享过一些相关的教程,包括WordPress主题开发教程和WordPress插件开发教程。
-
WordPress主题国际化WordPress主题国际化
暂无评论,抢个沙发...