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]
- Sticky Posts exceed posts per page limit
- Show all sticky posts, WITH pagination
- How do I set up real anonymous posting in bbpress forums? [closed]
- How to make “sticky” pages (and query by them)
- Sticky posts on home page, search, tag and archives without plugin
- WordPress 3.1 – How does one add sticky post capabilities to post types
- Get sticky post from category?
- How to make all posts in a category “unsticky”?
- Exclude Sticky posts from Main Query break Pagination
- How do I redirect users after submitting a replies for moderation on bbpress?
- How to make post sticky in the admin page?
- How do I find the bbpress forum ID for a forum in a buddypress group?
- How to retrieve “sticky” post outside the “loop”?
- What is best forum script available to integrate with wordpress?
- How to export bbPress (forums, topics, replies) and all users?
- I’d like to cycle through existing posts in a post type, showing one per day ordered by title, and starting over when the last is reached
- Sticky posts not working when a specific category is set
- bbPress plugin moderator roles
- WordPress change Language not working
- BBPress changing default group activity
- Disable email confirmation new register bbPress [closed]
- Use just a shortcode from another page
- bbPress: How to set conditional for specific user -or- user role, to be displayed in user profile
- Empty “Forums” page BuddyPress site wide forums – bbPress [closed]
- Custom loops, sticky posts, and pagination nightmare
- How to automate featured posts number? [duplicate]
- Exclude duplicated $sticky post from combined loop content
- Sticky option for custom post types without using custom fields or plugins
- How to add description over forum list on bbpress root page
- How to completely hide a WordPress/BuddyPress Install? [closed]
- Sticky posts don’t show up first in custom loop
- Make posts_per_page value the same on all pages
- How to remove ( 0, 0 ) from forum page in bbpress [closed]
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- Forum creation with bbpress and front end
- Seach and categories not working when ignoring sticky posts in main loop
- Pin to Top Functionality using orderby custom field then event date
- How to detect if bbPress forum index
- How to display only sticky posts on category pages?
- WP Query with sticky posts and tax_query
- Show sticky blog post on homepage
- Show sticky post before other WP_Query
- Limit Number of Sticky Posts to Show
- How to import data from Mingle Forum plugin to bbPress?
- How to change text (date) in post base on the day
- Multiple loops on index page with sticky post and pagination
- Form validation on user profile edit
- Custom Post Type Archive Title Lowercase
- How can a user login on a wordpress page?
- How can I display sticky posts at first in wp_query?
- How to enable truly anonymous posting in bbPress forums? [closed]
- Remove embed url for internal links
- How to show sticky posts on all pages of the pagination, not just the first page?