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]
- why ignore_sticky_posts in sticky post query
- Exclude sticky post from main query?
- How to prevent spam users registering even with registration disabled
- How can I pass a variable to wp_ajax action?
- Disable sticky posts feature
- Apply styling only to first page sticky posts
- How to make all posts in a category sticky?
- All sticky posts are returned in custom query
- Improving the Thesis built-in dropdown menu via javascript
- How to get the Role Name of the current user? (WordPress)
- “Sticky” posts for each category (archive.php)
- Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
- How do I Create Forums with bbpress Plugin that can only be Viewed by Logged in Users
- Change sticky status of posts from phpMyAdmin
- How to get 1 or 2 specific posts on top of my wordpress blog?
- Intermittent 404 errors, rewrite rules, and BBPress
- Custom Profile Fields move from BBpress to BuddyPress
- Using WordPress as an API [closed]
- Make sticky post on save
- WYSIWYG editor with image upload for “Normal Users” [closed]
- get_posts() not working in functions.php
- Require tags for bbPress topics [closed]
- How to convert WordPress comments to bbPress replies [closed]
- Header and nav menu problem on Thesis site [closed]
- Pin a post to the top of a page, other than the home page
- How can I allow sticky posts but cap the query to 1 post?
- Exclude all sticky posts front page twenty twelve
- Exclude first post (sticky or not) from the loop using query_posts()
- Custom query: how to get the sticky posts first?
- Display image for first sticky post only
- I would like to change the sticky posts label “Featured” to something else
- wp_list_authors() returning the wrong member url
- Include Buddypress & bbPress styles/scripts conditionally [closed]
- How do I determine if the user who registered is not spam?
- Category sticky latest
- How to get the post id (of the parent custom custom type) in a loop inside a widget?
- How to make the following loop break/stop when it reaches 2 posts (custom post types called Topics)?
- wordpress query_posts featured page always on top
- Sticky Post Doesn’t always work
- Make sticky post with FacetWP
- Latest Sticky Posts with Grid Thumbnails for static front page
- why ignore_sticky_posts in sticky post query
- How to stopping auto scrolling after submitting the form?
- How to enable truly anonymous posting in bbPress forums? [closed]
- Allow BBPress participant role to trash topics
- Trying to Exclude Sticky Posts From date_query
- Blog Displays Only Sticky Posts
- Set custom field value when reaching expiration date
- Insert/sticky multiple posts in multiple positions
- Jquery and Sticky
- How to display only sticky posts on my automatically generated front page?
- Images for sticky posts
- How can I locate the single buddypress forum post template? [closed]