[wp-trac] [WordPress Trac] #12702: Enable sticky post checkbox for custom post type Publish metabox

WordPress Trac noreply at wordpress.org
Wed Mar 9 22:01:30 UTC 2016


#12702: Enable sticky post checkbox for custom post type Publish metabox
-------------------------------------------------+-------------------------
 Reporter:  phlux0r                              |       Owner:
     Type:  feature request                      |      Status:  reopened
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Posts, Post Types                    |  Review
 Severity:  normal                               |     Version:
 Keywords:  dev-feedback has-patch 2nd-opinion   |  Resolution:
  close                                          |     Focuses:
-------------------------------------------------+-------------------------

Comment (by MrGregWaugh):

 Almost all of the functionality of this is complete and has been in core
 for a good while now.  The last piece is only that $post_type == 'post' is
 hard coded in the metabox UI.

 This proposal provides this functionality, using native WP structure.
 Specifically NO new filters, or wp-config variables or anything.  We have
 been maintaining this core hack for many versions, with no issues.

 Using post_type_supports(), one can add 'sticky' support when a post type
 is declared.  This would be completely backwards compatible, since
 existing post types wouldn't support 'sticky' by default.  It would be up
 to the developer to choose to use this feature where it is useful.

 For example, here is one (of only three) changes to core:

 {{{#!php
 <?php
 -} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
 +} elseif ( ($post_type == 'post' || post_type_supports( $post_type,
 'sticky' )) && is_sticky( $post->ID ) ) {
 }}}


 Attaching the three line patch that will complete this feature request:

 [https://core.trac.wordpress.org/raw-attachment/ticket/12702
 /wp_12702_meta-boxes_mgw_030916.diff]

--
Ticket URL: <https://core.trac.wordpress.org/ticket/12702#comment:65>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list