Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Ryan Hellyer on "Taxonomy bug"

$
0
0

I'm not sure if this is a bug in core or if I'm doing something wrong.

I have some code which generates a post-type called "Books" and I'm adding support for the post_tag taxonomy via register_taxonomy_for_object_type().

<?php

function test() {
	$args = array(
		'public' => true,
		'label'  => 'Books',
	);
	register_post_type( 'book', $args );

	register_taxonomy_for_object_type( 'post_tag', 'book' );
}
add_action( 'init', 'test' );

There are three posts in the book post-type:
http://uploads.ryanhellyer.net/random/2014/10/books-tags.png

Viewing the tags in the book post-type shows up all of the tags, including those from the posts post-type (note that the "Asten" tag indicates it has one post):
http://uploads.ryanhellyer.net/random/2014/10/books-tag.png

If I click on the Asten post tag, it displays no posts at all.
http://uploads.ryanhellyer.net/random/2014/10/books-tag-good.png

If I go to the posts post-type, the Asten post tag does show a post as expected:
http://uploads.ryanhellyer.net/random/2014/10/posts-tag.png

Question: Why does the "Asten" post tag display "1" when I'm on the book post-type? There is no post for the book post-type with a tag of "Asten" and so this should surely say "0" right? Clicking something which indicates there is one post, but it displaying zero does not make sense to me.


Viewing all articles
Browse latest Browse all 8245

Trending Articles