WordPress的自定义帖子
问题描述:
我是新的WordPress的世界。我成功创建了自定义帖子,并将其显示在页面模板页面上。现在我想使用taxonomy- {category} .php和single- {post} .php来显示自定义帖子,但是我在texonomy页面和sigle页面中感到困惑。如何工作和如何做。WordPress的自定义帖子
在taxonomy- {category} .php这里category是指我们的自定义类别名称或其他?
在single- {post} .php这里post表示自定义的帖子名称或其他吗?
请帮我解决这个问题。
在此先感谢。
答
- taxonomy- {}分类的.PHP Template_Hierarchy - 如果分类是sometax,WordPress的 会寻找分类,sometax.php
- 单{} post_type .php - 如果帖子类型是产品,WordPress会查找single-product.php。
例子:
对于post_type
当在后台在线商店自定义后的类型,URL会wp-admin/edit.php?post_type=store
。 因此,在这种情况下,post_type
是store
,这意味着我将其命名为我的文件single-store.php
对于分类
当在后台在线商店类别页面上,网址是edit-tags.php?taxonomy=store_categories&post_type=store
因此,分类文件将是taxonomy-store_categories.php
答
在taxonomy- {category} .php这里category是指我们的自定义类别名称还是其他?
taxonomy-{category}.php here category means your custom category(taxonomy)
在single- {post} .php这里post表示自定义的帖子名或其他吗?
single-{post}.php here post means custom post type name
感谢您的支持。如果我创建了分类名称“书”,所以我必须给taxonomy-book.php和这个分类页面自动显示从我的页面模板页面?我对吗? –
是的,你是对的... –