Make WordPress Core

Opened 14 years ago

Last modified 4 years ago

#16784 new enhancement

Introduce post_type_archive_description()

Reported by: thomask's profile thomask Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description (last modified by scribu)

if using the standard archive.php page, the common function for getting archive page name (e.g. single_tag_title) or description (e.g. tag_description) do not work - the best now is to use get_queried_object()->name resp. get_queried_object()->description

Also it is not obvious, that when you create a custom post type and taxonomy (with public=true) they are not visible on menu navigation page - you must make them visible using the top View menu (it took me a while to realize it)

Attachments (3)

16784.patch (1.5 KB) - added by Jayjdk 11 years ago.
16784.2.patch (1.5 KB) - added by Jayjdk 11 years ago.
Fix incorrect @since
16784.diff (1.5 KB) - added by iamfriendly 9 years ago.
Refreshed the patch

Download all attachments as: .zip

Change History (15)

#1 in reply to: ↑ description @duck_
14 years ago

  • Keywords close added

Replying to thomask:

  1. it is not possible to add it using Nav menus (except direct Custom link)

#16075

  1. if using the standard archive.php page, the common function for getting archive page name (e.g. single_tag_title) or description (e.g. tag_description) do not work - the best now is to use get_queried_object()->name resp. get_queried_object()->description

post_type_archive_title. There is no way that single_tag_title is supposed to work as it is clearly for use with tag archives. You can also use is_post_type_archive to determine if the current page is a post type archive.

Suggesting close as dupe of #16075 for the first problem.

#2 @thomask
14 years ago

sorry, have not noticed #16075. Ad (2) - the post_type_archive_title is great, i have missed it and is probably exactly what i thought, what should be added then is also post_type_archive_description function.

#3 @scribu
14 years ago

  • Summary changed from Custom post type archive limited to Introduce post_type_archive_description()

post_type_archive_description() would require a place to store the description in the first place. Maybe a 'archive_description' arg on register_post_type() ?

#4 @scribu
14 years ago

  • Description modified (diff)
  • Keywords close removed

Nevermind, I see there already is a 'description' arg.

#5 @c3mdigital
11 years ago

  • Keywords needs-patch added

@Jayjdk
11 years ago

#6 @Jayjdk
11 years ago

I have attached a patch.

The function is quite similar to post_type_archive_title() but I removed the $prefix parameter.

This function echo as default similar to post_type_archive_title() but the other description functions returns as default. I'm not sure what's preferred here.

I'm not not sure what file this function should be in. post_type_archive_title() is in general-template.php but term_description() and the others are in category-template.php. I've included the function right after post_type_archive_title().

@Jayjdk
11 years ago

Fix incorrect @since

#7 @Jayjdk
11 years ago

  • Keywords has-patch added; needs-patch removed

#8 @lkraav
11 years ago

+1 this function is consistent with taxonomy stuff and should exist in core.

#9 @lkraav
11 years ago

This beast should also be user-editable. Post type archives can be significant landing pages and could use a bunch of copy up top. Initial thought is the logical place would be a separate menu item below the CPT item hierarchy. Anyone else here agree?

#10 @wonderboymusic
9 years ago

  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to Future Release

Patch still applies but has wrong @since docs

@iamfriendly
9 years ago

Refreshed the patch

#11 @iamfriendly
9 years ago

  • Keywords needs-refresh removed

Patch refreshed with correct @since docs

#12 @jorbin
4 years ago

  • Keywords needs-unit-tests added

This could use some unit tests. I also think it would be good to allow passing in of a post_type so it can be used outside of specific templates.

Note: See TracTickets for help on using tickets.