WordPress外贸网站SEO优化:如何为页面添加分类和标签
WordPress外贸网站SEO优化:如何为页面添加分类和标签
WordPress SEO Optimization for Foreign Trade Websites: How to Add Categories and Tags to Pages
作者:悦然WordPress建站 (专业外贸网站建设专家)
使用WordPress建设外贸网站时,我们通常通过文章(Posts)和页面(Pages)两种形式来更新内容。虽然基本编辑功能相同,但默认情况下WordPress页面无法添加标签和分类。本文将分享两种专业方法,帮助您为WordPress网站的页面添加分类和标签属性,提升SEO效果。
方法一:使用插件(推荐新手)
最简单的方法是安装Post Tags and Categories for Pages插件:
1. 在WordPress后台搜索该插件
2. 安装并激活
3. 无需额外设置即可使用
Method 1: Using Plugin (Recommended for Beginners)
The easiest way is to install the Post Tags and Categories for Pages plugin:
1. Search for the plugin in WordPress dashboard
2. Install and activate
3. No additional setup required
方法二:添加代码(适合开发者)
如果您的网站已安装较多插件,或遇到兼容性问题,可以通过添加以下代码实现:
class PTCFP{ function __construct(){ add_action( 'init', array( $this, 'taxonomies_for_pages' ) ); if ( ! is_admin() ) { add_action( 'pre_get_posts', array( $this, 'category_archives' ) ); add_action( 'pre_get_posts', array( $this, 'tags_archives' ) ); } } function taxonomies_for_pages() { register_taxonomy_for_object_type( 'post_tag', 'page' ); register_taxonomy_for_object_type( 'category', 'page' ); } function tags_archives( $wp_query ) { if ( $wp_query->get( 'tag' ) ) $wp_query->set( 'post_type', 'any' ); } function category_archives( $wp_query ) { if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) ) $wp_query->set( 'post_type', 'any' ); } } $ptcfp = new PTCFP();
操作步骤:将代码添加到当前主题的functions.php文件中,保存后刷新后台。
Method 2: Adding Code (For Developers)
If your site has many plugins or compatibility issues, you can add the following code:
Steps: Add the code to your theme's functions.php file, save and refresh the dashboard.
SEO效果与建议
成功添加后,页面编辑界面将出现分类和标签选项:
✓ 提升页面在分类存档中的曝光率
✓ 增强标签云的相关性
✓ 改善网站内部链接结构
但需注意:过度使用可能影响网站架构清晰度,建议仅对重要页面使用。
SEO Effects and Suggestions
After successful addition, category and tag options will appear:
✓ Increase page visibility in category archives
✓ Enhance tag cloud relevance
✓ Improve internal linking structure
Note: Overuse may affect site architecture clarity, recommended for important pages only.
外贸网站特别提示
对于外贸网站,合理使用页面分类和标签可以:
• 更好地组织多语言产品页面
• 提升Google Ads推广效果
• 优化谷歌竞价广告的着陆页结构
Special Tips for Foreign Trade Websites
For foreign trade websites, proper use can:
• Better organize multilingual product pages
• Improve Google Ads performance
• Optimize landing page structure for Google Ads
