Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 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: henry.wright Owned by: DrewAPicture
Priority: normal Milestone: 4.9
Component: Posts, Post Types Version: 4.6.1
Severity: normal Keywords: has-patch
Cc: Focuses: template

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 10 years ago.

Download all attachments as: .zip

Change History (14)

#1 @swissspidy
10 years ago

  • Component General → Posts, Post Types
  • Focuses template added

Related: #37535

#2 @swb1192
10 years ago

Is there a workaround for this?

#3 @swissspidy
10 years ago

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

#4 @henry.wright
10 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
10 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → Future Release

@henry.wright
10 years ago

#6 @henry.wright
10 years ago

  • Keywords has-patch added; needs-patch removed

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

#7 @DrewAPicture
9 years ago

#34656 was marked as a duplicate.

#8 @DrewAPicture
9 years ago

  • Milestone Future Release → 4.9

#9 @DrewAPicture
9 years ago

  • Owner set to DrewAPicture
  • Resolution → fixed
  • Status new → 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
9 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
9 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
9 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
9 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.