wordpress:如何在页面上添加类别和标签? [英] wordpress : how to add categories and tags on pages?

查看:32
本文介绍了wordpress:如何在页面上添加类别和标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过在我的主题目录中创建一个 php 文件使用自定义模板生成了页面类似的东西:

I have generated pages using a custom template by creating a php file in my theme directory something like :

<?php
 *
 * Template Name: Contact Page
 */
 ?>
 <html ..... </html>

然后在仪表板上添加一个新页面,选择这个新模板

and then adding a new page on the dashboard selecting this new template

我现在如何将标签和类别关联到每个页面?创建帖子而不是页面是唯一的解决方案吗?

How can i now associate tags and categories to each pages ? Is creating posts instead of pages the only solution?

推荐答案

更好的是添加到您的主题文件夹中的functions.php:

Even better is to add to functions.php in your theme folder:

function myplugin_settings() {  
    // Add tag metabox to page
    register_taxonomy_for_object_type('post_tag', 'page'); 
    // Add category metabox to page
    register_taxonomy_for_object_type('category', 'page');  
}
 // Add to the admin_init hook of your theme functions.php file 
add_action( 'init', 'myplugin_settings' );

这篇关于wordpress:如何在页面上添加类别和标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆