[wp-trac] [WordPress Trac] #33921: Twenty Fourteen: Featured_Content::get_sticky_posts() getting also non published posts

WordPress Trac noreply at wordpress.org
Fri Sep 18 11:46:45 UTC 2015


#33921: Twenty Fourteen: Featured_Content::get_sticky_posts() getting also non
published posts
---------------------------+-----------------------------
 Reporter:  stode          |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:  accessibility  |
---------------------------+-----------------------------
 As the method static method {{{ Featured_Content::get_sticky_posts() }}}
 only gets the '''sticky_post''' IDs from '''wp_options''' table, but does
 not check that the  '''post_status''' is equal to '''publish''.

 My suggestion would be:

 {{{
 /**
 * Return an array with IDs of posts marked as sticky.
 *
 * @static
 * @access public
 * @since Twenty Fourteen 1.0
 *
 * @return array Array of published sticky posts.
 */
 public static function get_sticky_posts() {

                  $args = array(
                         'fields'           => 'ids',
                         'numberposts'      => self::$max_posts,
                         'post_type'        => 'post',
                         'post_status'      => 'publish',
                         'suppress_filters' => false,
                         'post__in'         => get_option( 'sticky_posts' ,
 array()),
                 );
                 $sticky_post_ids = get_posts( $args );

                 return $sticky_post_ids;
         }
 }}}

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


More information about the wp-trac mailing list