WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 2 years ago

#14370 closed defect (bug) (invalid)

Custom Taxonomies tagging Attachments

Reported by: 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 5 years ago.
Tax tag from Media
Screen shot 2010-07-26 at 10.02.12 PM.png (36.1 KB) - added by thee17 5 years ago.
Tax Tag from Uploader

Download all attachments as: .zip

Change History (20)

comment:1 @scribu5 years ago

  • Keywords reporter-feedback added; needs-patch removed

Could you post more detailed steps to reproduce?

comment:2 follow-up: @thee175 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.)

comment:3 @thee175 years ago

  • Keywords reporter-feedback removed

comment:4 @thee175 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.

comment:5 @mikeschinkel5 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.

comment:6 @thee175 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.

comment:7 @mikeschinkel5 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?

@thee175 years ago

Tax tag from Media

@thee175 years ago

Tax Tag from Uploader

comment:8 @thee175 years ago

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

comment:9 in reply to: ↑ 2 @mikeschinkel5 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?

comment:10 @mikeschinkel5 years ago

Oops, meant to ask:

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

comment:11 @thee175 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 2 years ago by thee17 (previous) (diff)

comment:12 @mikeschinkel5 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.)

comment:13 @wonderboymusic3 years ago

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

comment:14 @thee173 years ago

How so is this invalid?

comment:15 @SergeyBiryukov3 years ago

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

comment:17 @wonderboymusic2 years ago

  • Keywords needs-patch added; dev-feedback removed

comment:18 @helen2 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.