Make WordPress Core

Opened 13 years ago

Closed 10 years ago

#14370 closed defect (bug) (invalid)

Custom Taxonomies tagging Attachments

Reported by: thee17's profile thee17 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords:
Focuses: Cc:

Description

There appears to be an issue where if the custom taxonomy has only attachment:image, attachment:audio, and attachment:video The attachments return nothing found. Only 'post' post types are returned.

adding to a query 'post_status' => publish, allows it to display the images but does not allow pagination.

WordPress should return all post_types that the Taxonomy is defined for. Somehow ma.tt found a way around this issue. refer to:
http://osdir.com/ml/wp-testers/2010-06/msg00317.html
http://wordpress.org/support/topic/383096?replies=29

Does not affect pre 3.0

Attachments (2)

Screen shot 2010-07-26 at 10.01.03 PM.png (94.3 KB) - added by thee17 13 years ago.
Tax tag from Media
Screen shot 2010-07-26 at 10.02.12 PM.png (36.1 KB) - added by thee17 13 years ago.
Tax Tag from Uploader

Download all attachments as: .zip

Change History (20)

#1 @scribu
13 years ago

  • Keywords reporter-feedback added; needs-patch removed

Could you post more detailed steps to reproduce?

#2 follow-up: @thee17
13 years ago

1) Create a Taxonomy for attachment:image (such as Matt's Community Tags plugin does)
2) Tag photos with a single tag, that it begins to page (will work as expected with 'post' post_type).
3) No images will show unless ('post_status' => publish) is used in a query.
4) Click Next Page. A 404 error will occur. (thought it might be a permalink error but it does this without permalink.)

#3 @thee17
13 years ago

  • Keywords reporter-feedback removed

#4 @thee17
13 years ago

  • Keywords dev-feedback added
  • Summary changed from Pagination and Custom Taxonomies to Custom Taxonomies tagging Attachments

I think I have narrowed down the problem, when calling the taxonomy only a 'published' post_status is being returned, attachments all have the post_status 'inherit'.

Modifiying the wp-includes/post.php to have 'inherit' as 'public' => true then it works as expected.

Obviously setting inherit to public is not the best option. Perhaps we need something when generating a custom tax page that if it is inherit and an attachment to determine the attachment's attached post's post_status and us it instead.

#5 @mikeschinkel
13 years ago

  • Cc mikeschinkel@… added

I don't think I fully understand the issue. When you say "Tag photo" are you tagging a post that has a photo associated with it, or somehow directly tagging the attachment? Can you provide the admin URL that you are using to tag the photo and also a screen shot so I can see what you are doing?

Can you provide your register_taxonomy() calls and the URLs on the external website describing where you have a problem with each?

If I can figure out what the actually problem is I'm sure we can find a solution.

#6 @thee17
13 years ago

Okay to begin with you create the tax

      register_taxonomy(
               'people',
               array('attachment:image', 'attachment:video', 'attachment:audio'),
		array(
			'label' => __('People'),
			'template' => __('People: %l.'),
			'helps' => __('Separate people with commas.'),
			'show_ui' => true,
			'sort' => true,
			'args' => array('orderby' => 'term_order'),
			'rewrite' => array('slug' => 'person'),
               )
       );

As you can see it is a tax that is only linked to an attachment post_type of images, video and audio.

From here you can tag the attachments from the Media admin (a People: field appears) or Matt's Community Tags plugin.

At this point the taxonomy page reveals no results. If you assign the Tax to pages it works as expected, but only pages show. Custom Post Types are tested to work as well with a 'publish' post_status.

Attachment post_type by their nature have an 'inherit' post status that is not set to 'public', if 'inherit' is defined to be a public status than images appear and page properly.

The following code will override in the theme template but will not page.

<?php global $wp_query;
query_posts(
	array_merge(
		array('post_status' => publish,),
		$wp_query->query
	)
);
 ?>

Therefore attachment is not inheriting its status from it's attached post_type properly. This used to work in 2.9.2 but something changed in 3.0.

#7 @mikeschinkel
13 years ago

I'm not familiar with the syntax you are using with the colons and the image, video and audio designation. Is that recognized by WordPress? And I don't se any way to tag attachments, at least not with WordPress 3.0 core. Sounds like this is something related to the Community Tags plugin you are using and not WordPress itself?

@thee17
13 years ago

Tax tag from Media

@thee17
13 years ago

Tax Tag from Uploader

#8 @thee17
13 years ago

the :image defines the mime type of the attachment the same as image.php in the template hierarchy.

#9 in reply to: ↑ 2 @mikeschinkel
13 years ago

Replying to thee17:

1) Create a Taxonomy for attachment:image (such as Matt's Community Tags plugin does)
2) Tag photos with a single tag, that it begins to page (will work as expected with 'post' post_type).
3) No images will show unless ('post_status' => publish) is used in a query.
4) Click Next Page. A 404 error will occur. (thought it might be a permalink error but it does this without permalink.)

What are the URLs: 1.) for the page that displays correct and for the 404 error page?

#10 @mikeschinkel
13 years ago

Oops, meant to ask:

What are the URLs: 1.) for the page that displays correct and 2.) for the 404 error page?

#11 @thee17
13 years ago

This works by forcing the template file to accept the "'post_status' => publish"
http://cefm.ca/people/charles-frees-melvin/

However, the following would not work as the query does not call a page to have a template override because it believes there is no content to allow for a second page.
http://cefm.ca/people/charles-frees-melvin/page/2/

I have in production disabled paging in the templae file until resolved but the real issue it the inherit post_status not pulling it's attributes properly (I think from wp-includes/query.php file.)

The title of this ticket should probably be changed to "Attachment listings not pulling proper post_status".

Last edited 10 years ago by thee17 (previous) (diff)

#12 @mikeschinkel
13 years ago

Sorry, this is becoming more like a support question and I unfortunately don't have time to set up the data to be able to figure out what it going wrong. It may be a bug but it's not similar to any use-cases I often work with so someone else will have to resolve it. If you want to figure out what's happening, get yourself something like PhpStorm with XDEBUG setup and trace through the code until you figure it out (that's what I use for this kind of stuff.)

#13 @wonderboymusic
11 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#14 @thee17
11 years ago

How so is this invalid?

#15 @SergeyBiryukov
11 years ago

  • Resolution invalid deleted
  • Severity changed from major to normal
  • Status changed from closed to reopened

#17 @wonderboymusic
10 years ago

  • Keywords needs-patch added; dev-feedback removed

#18 @helen
10 years ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

You need to use pre_get_posts for working pagination, not query_posts(). There you can add the inherit post status to the query where appropriate.

Note: See TracTickets for help on using tickets.