Use the below code in the mainpage template to show the sticky posts.
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
The above will print the title of the sticky posts
Related Posts:
- Using categories & “stickyness” together
- Sticky posts on home page, search, tag and archives without plugin
- How to make all posts in a category sticky?
- Sticky Posts Not Sticking to Top of Category Archive
- How to make all posts in a category “unsticky”?
- “Sticky” posts for each category (archive.php)
- Stick multiple posts in a single category
- Sticky posts not working when a specific category is set
- Sticky post for each category on category pages [duplicate]
- How to display sticky or latest published post on the current category page it belongs to?
- Category sticky latest
- How do you get sticky posts to work with categories?
- How to display only sticky posts on category pages?
- Get posts from sites in Multisite?
- How to create a custom sort for WordPress categories
- Hook when category is added to post
- How to add the category ID to admin page
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- WordPress remove separator from last item in wp_list_categories
- Filter categories using tags
- Need help adding custom field to category
- Show Post from parent category (custom taxonomy) ONLY!
- How to display a list of categories
- One WordPress Install, Two Categories. Each Category Gets a Domain
- Create single.php for specific category by category id
- is_category in pre_get_posts results in php notices
- Filtering Children of the “uncategorized” Category out of the Loop?
- Add a wordpress blog to my website having users
- Allow contributors to add categories, but not delete
- in_category() not working in WordPress 4.9.7
- PHP Fatal error: Cannot use object of type WP_REST_Response as array in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- WordPress categories being called “archives” in google links. How to remove?
- Show recent posts from one category on a non-WP site
- Omit specific product categories from WooCommerce shortcode
- Inserting Category programmatically
- Category-slug.php not being used
- Additional form options based on category selected not working
- Pagination for category slug returns 404 when page >= 2
- Display category-specific comments in sidebar
- I want to display posts common in 3 categories [closed]
- Paging not working in category.php
- Display list of categories filtered by date?
- Drop posts from categories in MySql
- Redirect single article permalink to paginated category page
- Exclude category by slug in pre_get_posts?
- add slug beside name in Admin Category Checklists
- How to show 5 posts from specific category on related page?
- Author Page – List of categories plus number of posts in that category
- Exclude category from related post
- Post belonging to many categories
- how do I use the walker class to display categories in their correct heirarchy?
- How can you access category information from a theme?
- Filter WooCommerce archive pages by an additional category
- WP 4.7 in_category change?
- display category list year wise in wordpress
- Display subcategories in dropdown
- Illegal string offset ‘taxonomy’ in
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Category Page Template – Can’t get category ID
- Are term_taxonomy_id and term_id the same? [duplicate]
- Display all sub category but one
- Filter Category Loop Dynamically
- SQL query to get posts from multiple categories but not in a category
- Can each user have only access to a private area (his own categories and posts)?
- WP Category Meta plugin fix? [closed]
- WP SQL Categories Export and Import
- How to display WooCommerce category image in my category page banner as a background?
- Why are my newly added categories not showing up when creating a post?
- WordPress Default Category and Custom Taxonomy Selected Attribute not Working After Searched in wp_dropdown_categories Array
- Order wp_dropdown_categories by ASC or DESC
- Add filter for specific category only
- How to exclude a category returned by get_categories from function.php?
- Get a list of categories, separated by / to display inside the for custom metatags
- Displaying only selected categories
- get_the_category vs wp_get_post_categories
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- Getting a sub category based on a category name
- Conditional statement: if is_category, append at the end of page
- I have many different products on my website how can I get them to display under specific categories?
- Help with SQL query, how to add taxonomie terms with value stored in options?
- /blog/ permalink prefix causes category pages to 404
- How to create an array with category ids order by the one that has the most recent post
- WordPress Shop and restricting products and categories for some users/groups
- Pass list of categories to JS
- WP url to get rss with full text of post
- Display Referring Category on single post?
- Conditional statements based on custom meta value in category archives
- Placement of categories
- Paginating a list of all posts collected by category titles
- Display deepest post category, when post have multiple categories
- Paginate WordPress Category Pages
- Get a list of post titles and links from yootheme master theme
- How to structure Multisite sites into categories?
- Customize category query in widget
- Page permalink rewrite
- Template files not working for archives and categories
- Broken category styling
- Excluding cateory not working on my site. how to solve this? [closed]
- Get all first images of posts in same category
- Woocommerce Force the category choice before creating new product? [duplicate]