2
WPページにカテゴリとタグを追加できるように、Wordpressプラグインにhttp://shibashake.com/wordpress-theme/add-tags-and-categories-to-your-wordpress-pageというコードをラップしました。パーマリンク設定によるWordpress add_filterの問題
パーマリンクがデフォルトに設定されていると、カテゴリウィジェットからのフィルタリングが失敗します。
myblog.com/?cat=8
他のパーマリンク構造を持つ。
myblog.com/category/news
すべてが問題ありません。
ここにプラグインコードがあります - すべてのパーマリンクタイプに対応するためにmy_expanded_request関数をどのように変更できますか? TagPages - -
<?php
/**
* @package Categories and Tags For Pages
* @version 0.1
*/
/*
Plugin Name: Categories and Tags For Pages
Plugin URI: http://wordpress.org/#
Description: Expands category and tag options to include pages
Author: Me
Version: 0.1
*/
function add_page_cats_and_tags() {
register_taxonomy_for_object_type('post_tag', 'page');
register_taxonomy_for_object_type('category', 'page');
}
add_action('admin_init', 'add_page_cats_and_tags');
function my_expanded_request($q) {
if (isset($q['tag']) || isset($q['category_name'])) {
$q['post_type'] = array('post', 'page');
}
return $q;
}
add_filter('request', 'my_expanded_request');
?>