Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#38487 closed enhancement (fixed)

the_archive_description() doesn't output the custom post type description when used in a post type archive template

Reported by: henrywright's profile henry.wright Owned by: drewapicture's profile DrewAPicture
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.6.1
Component: Posts, Post Types Keywords: has-patch
Focuses: template Cc:

Description

When registering a custom post type using register_post_type(), we can provide a CPT description using the description param.

If the_archive_description() is used in a custom post type archive template, the CPT description doesn't get outputted.

Attachments (1)

38487.diff (855 bytes) - added by henry.wright 8 years ago.

Download all attachments as: .zip

Change History (14)

#1 @swissspidy
8 years ago

  • Component changed from General to Posts, Post Types
  • Focuses template added

Related: #37535

#2 @swb1192
8 years ago

Is there a workaround for this?

#3 @swissspidy
8 years ago

@swb1192 the_archive_description() has a filter that you can use to display the post type description yourself.

#4 @henry.wright
8 years ago

Further to @swissspidy's post above, you may need is_post_type_archive() if your filter function is in a plugin or in your functions file.

Ref https://codex.wordpress.org/Function_Reference/is_post_type_archive

#5 @SergeyBiryukov
8 years ago

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

@henry.wright
8 years ago

#6 @henry.wright
8 years ago

  • Keywords has-patch added; needs-patch removed

38487.diff will output the custom post description in custom post archives.

#7 @DrewAPicture
7 years ago

#34656 was marked as a duplicate.

#8 @DrewAPicture
7 years ago

  • Milestone changed from Future Release to 4.9

#9 @DrewAPicture
7 years ago

  • Owner set to DrewAPicture
  • Resolution set to fixed
  • Status changed from new to closed

In 40976:

General: Add support for the post type archive description to get_the_archive_description(), and thereby also the_archive_description().

Props henrywright.
Fixes #38487.

#10 @DrewAPicture
7 years ago

In 40977:

Remove an unnecessary initialization of $description due to the else condition in get_the_archive_description().

See [40976]. See #38487.

#11 follow-up: @henry.wright
7 years ago

Hey @DrewAPicture

In the commit, if post_type_obj->description isn't set, $description doesn't get set. Does that matter?

#12 in reply to: ↑ 11 @DrewAPicture
7 years ago

Replying to henry.wright:

Hey @DrewAPicture

In the commit, if post_type_obj->description isn't set, $description doesn't get set. Does that matter?

It does matter, yes :-) I removed the initialization thinking that I'd left the fallback from your original patch in there, but I didn't. Good catch.

#13 @DrewAPicture
7 years ago

In 40983:

General: Ensure $description gets initialized in get_the_archive_description() if the post type archive conditional is true and the description isn't set.

Props henrywright.
See #38487.

Note: See TracTickets for help on using tickets.