Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Query to display sticky posts only

  • @darraghdeveire

    Participant

    Hi, I’m looking for a solution to display a list of sticky posts. I currently have a list of all recent topics displaying -> http://kohler.surefiresocial.com/featured-articles/ but I want to restrict this to just sticky posts. I am using the short-code [bbp-topic-index] to display the topic index.

    Basically, I am stuck as to should i modify and create a short-code or drop in a custom query? any help would be greatly appreciated.

    Thanks in advance.

    WP Version – 3.8
    BBPress Version – 2.5.1
    URL – http://kohler.surefiresocial.com/featured-articles/

Viewing 3 replies - 1 through 3 (of 3 total)
  • @mvaneijgen

    Participant

    Did you found anything?

    @_az_

    Participant

    There is a function: bbp_get_super_stickies() which is used inside the function bbp_has_topics(). This function basically returns a list of Post IDs from the wp_options table from a row with the key: “_bbp_super_sticky_topics” or “_bbp_sticky_topics”

    So one approach could be: override default args

    bbp_has_topics(array('show_stickies' => false);

    Extra loop for stickys (not tested, just a sketch)

    $query = new WP_Query(array('inlucde' => bbp_get_super_stickies());

    Though i recommend looking into the function bbp_has_topics to be aware of all possible cases.

    @_az_

    Participant

    update: replace ‘include’ with ‘post__in’ and then its a loop just with super-stickies

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar