[wp-trac] [WordPress Trac] #52404: Fix get_the_archive_description() to support default blog index

WordPress Trac noreply at wordpress.org
Sat Jan 30 12:33:04 UTC 2021


#52404: Fix get_the_archive_description() to support default blog index
------------------------------+-----------------------------
 Reporter:  jaakkosaarenketo  |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  General           |    Version:  5.6
 Severity:  normal            |   Keywords:
  Focuses:  template          |
------------------------------+-----------------------------
 get_the_archive_description() returns nothing when viewing the default
 blog index.
 When viewing a custom post type index, it returns the description
 parameter but even if I add the description to 'post' nothing is
 displayed.

 The fix requires only adding additional is_home() check to
 is_post_type_archive() condition in get_the_archive_description() and
 setting a fallback $post_type = 'post' in get_the_post_type_description().

 '''Note that description for 'post' doesn't exist by default so this
 shouldn't cause any surprising changes.''' It just makes the function more
 logical.

 With these to very minor changes, adding archive description for blog
 index is possible by a filter such as:

 {{{
 function add_description_to_default_archive( $args, $post_type ) {

   if( 'post' == $post_type ) {
     $args['description'] = 'Enjoy our posts!';
   }

   return $args;
 }
 add_filter( 'register_post_type_args',
 'add_description_to_default_archive', 10, 2 );
 }}}

 I'll make a pull request of the changes in github.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52404>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list