﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
17290,"register_taxonomy_for_object_type('post_tag', 'page') does not include all registered post-types",neoxx,,"Hi,

I use `register_taxonomy_for_object_type('post_tag', 'page');` in my plugin [http://wordpress.org/extend/plugins/tagpages/ TagPages].

Everything works fine, though on a tag-page (`is_tag()==true`) only posts are shown in the results. I think this might have historical reasons but with the extended 3.0 taxonomy features we should maybe rethink this behavior and set the post_type for tag-pages to ''all post-tag registered post_types''.

Credits go to mitcho who raised this question in [http://wordpress.org/support/topic/plugin-tagpages-why-not-use-builtin-taxonmy-functionality#post-2030729 a support topic].

Here's the code I plan to use in the next version of TagPages (currently I manipulate the SQL WHERE directly) to include pages in tag-queries:

{{{
add_filter('pre_get_posts', array(&$this, 'add_page_to_tags_query'));

function add_page_to_tags_query($query) {
	if (is_tag() && !is_admin()) {

		/*
		if the post_type does not exist,
		we create it
		*/

		if (!array_key_exists('post_type', $query->query_vars))
			$query->query_vars['post_type']=array();

		/*
		if post_type is set to or includes
		any or page
		there's nothing more to do
		*/

		if (!empty($query->query_vars['post_type']) && (in_array('any', (array) $query->query_vars['post_type']) || (in_array('page', (array) $query->query_vars['post_type']))))
			return $query;

		/*
		otherwise include post and page
		into post_type
		*/

		$query->query_vars['post_type']=array_unique(array_merge((array) $query->query_vars['post_type'], array('post', 'page')));
	}

	return $query;
}

}}}

Greetz,
Berny",defect (bug),closed,normal,,Taxonomy,3.1,normal,duplicate,,
