You can make the query like above using following code.
<?php
query_posts( array( 'posts_per_page' => 2, 'meta_key' => '_bbp_sticky_topics', 'post_type'=> 'topic', 'order' => 'ASC' ) );
if (have_posts()) :
while (have_posts()) : the_post();
//do something
endwhile;
endif;
?>
But i strongly recommend you not to alter main query using query_posts() and instead use WP_Query as following.
<?php
$query = new WP_Query( array( 'posts_per_page' => 2, 'meta_key' => '_bbp_sticky_topics', 'post_type'=> 'topic', 'order' => 'ASC' ) );
if ( $query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
//do something
endwhile;
endif;
/* Restore original Post Data */
wp_reset_postdata();
?>
Related Posts:
- How to Detect if I am on a bbpress ‘plugin’ page?
- How to change the text of link ‘Home’ in bbPress forum breadcrumb?
- How to create a custom nested loop in bbPress (WordPress + bbPress plugin)
- How to change role titles in Bbpress?
- bbPress or WordPress + forum plugin?
- BBpress error wp-init [closed]
- Where does bbPress store author info for anonymous users?
- how to edit bbp_forum_freshness_link() format
- BBPress private topics by default
- Conditional if statement ($post->ID == get_the_ID) not working
- How to add more fields to bbPress registration form
- bbPress replies list
- BBPress bbp_new_reply action not firing when user replies to embedded thread
- How to disallow participant from publishing topics(bbpress)?
- wp_delete_post() not working with BBpress replies
- How to display BBpress statistics?
- Trouble installing bbpress [closed]
- How to disable sidebar only in bbPress and not WordPress?
- How to show recents topics below the forum’s title (WordPress + bbPress plugin)?
- How to add ‘Views’ in the forums page of bbPress (plugin)?
- How do I remove certain fields from the forum edit my profile page?
- How can i show Cubepoints ranks/points in bbpress replies
- Arrange BBpress replies in reverse order
- Avatar picture does not display when using get_avatar
- Team Collaboration in WordPress
- Post and bbpress – link discuss on forum
- Setup login/register buttons for bbPress?
- pre_get_posts and BBPress in Swagger Theme
- Change the avatar ratio in bbPress login widget
- what is the topic-view page’s name? in bbpress
- Suggestions to prepare a site which is 90% based on a plugin that’s still on beta stage?
- How to exclude one parent id from post_parent’ => ‘any’, in WordPress / bbPress?
- Scrolling on reply url
- Get rid of the word private in bbpress forums names
- How to add class to bbPress bbp_get_topic_author_link()?
- Add QuickTag in bbpress replies
- If post type = forum then breadcrumbs Home > Forums
- Connect WordPress comment moderation with bbPress Moderation plugin
- bbPress – Post count increases after every edit
- How to remove br and p tags from bbPress
- How to use the bbPress import tool
- bbpress plugin moderation
- bbPress plugin – How do I add a forum description?
- bbpress Not Showing: How to troubleshoot?
- bbPress – select a topic reply as “answer”
- bbPress is not displaying video player
- Show the parent forum in a topic with bbPress [closed]
- Unable to access bbPress forum pages though the content still there
- Sticky Posts exceed posts per page limit
- Integrate WordPress and bbpress profiles?
- why ignore_sticky_posts in sticky post query
- Add custom menu item using wp_nav_menu_items filter
- How to keep plugin translations after updates?
- How to add “Stick this post to the front page” to front end?
- Code to make a post sticky
- WP_Query: Why is sticky post not first item in loop?
- Seamless integration between WordPress and BBpress
- How to edit posts with the new wp_editor api?
- Query *only* sticky posts
- Exclude sticky post from main query?
- Show Sticky Posts in Category Archive
- Set sticky posts schedule (Automatic)
- Show all sticky posts, WITH pagination
- Sticky Posts & Posts Per Page [closed]
- Ensuring sticky posts are retrieved first (without using two queries)?
- Highlight a Featured Post?
- How do I set up real anonymous posting in bbpress forums? [closed]
- How to make my front page display only the most recent sticky post, plus usual widgets?
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- how to redirect to a custom password retrieval page
- How do I show sticky posts on a static front page that also contains content?
- Slideshow control for use in WordPress Thesis theme – non flash
- Add a single featured post to all pages?
- How to prevent spam users registering even with registration disabled
- How to edit bbPress template files – WordPress + BuddyPress + bbPress? [closed]
- Using categories & “stickyness” together
- How can I pass a variable to wp_ajax action?
- Sticky posts on home page, search, tag and archives without plugin
- How to retrieve sticky post in raw sql?
- WordPress 3.1 – How does one add sticky post capabilities to post types
- How to change “permalink” structure in “WordPress Thesis” theme?
- Display only the most recent sticky post, display other posts in chronological order
- Disable sticky posts feature
- Apply styling only to first page sticky posts
- Include sticky posts in ‘Blog pages show at most’ X number of posts?
- Include Sticky Post in Page Posts Count?
- wp_query for the first sticky, then display the rest of the posts excluding the first sticky
- Adding Sticky functionality to Custom Post Type Archives
- Schedule Sticky Posts
- How to make all posts in a category sticky?
- Display All Sticky Post Before Regular Post
- Sticky Posts Not Sticking to Top of Category Archive
- All sticky posts are returned in custom query
- Randomly placed sticky custom posts complemented by blog posts
- how to make custom posts sticky? [duplicate]
- Improving the Thesis built-in dropdown menu via javascript
- Get sticky post from category?
- How to make all posts in a category “unsticky”?
- How to get the Role Name of the current user? (WordPress)