How to display only sticky posts on category pages?

You can try to fetch the sticky posts IDs from the sticky_posts option and then modify the main query on the category archives accordingly: /** * Category Archives: Only display sticky posts for each category term */ add_action( ‘pre_get_posts’, function( \WP_Query $q ) { if( ! is_admin() && $q->is_category() && $q->is_main_query() ) { $sticky_posts = … Read more

WP_Query causing links to not work

I’m sorry. I didn’t create a single.php file. In my learnings I have discovered that if no single.php file exist then WordPress falls back to index.php. So the link were actually working but just using the same template. Again im sorry for wasting your time.

Pull posts from all categories if quantity is not met?

I would start by creating an array to put your posts into, to create a counting system of some kind. Dump your list item output into that array, count it, and use the remaining count to call your second query. <?php $term = get_term_by(‘slug’, get_query_var(‘term’), get_query_var(‘taxonomy’)); $sticky = get_option(‘sticky_posts’); // Moved the base arguments into … Read more

Pin to Top Functionality using orderby custom field then event date

I had a similar aproach some days ago //….. ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘pin_clause’ = array( ‘meta_key’ => ‘pin_to_top’, ‘meta_type’ => ‘NUMERIC’, ‘meta_value_num’ => ‘1’, ‘compare’ => ‘=’ ) ), array( ‘date_clause’ => array( ‘meta_key’ => ‘_EventStartDate’, ‘meta_type’ => ‘DATETIME’, ‘meta_value’ => ‘$today’, ‘compare’ => ‘>=’ ) ) ), ‘orderby’ => array( … Read more

why ignore_sticky_posts in sticky post query

We all know that ignore_sticky_posts is used to exclude sticky post from your custom query. – No, this assumption is wrong. What ignore_sticky_posts means: Even though in natural English, ignore_sticky_posts sounds like WordPress should ignore all sticky posts from the query, in reality that is not what WordPress does. Instead, you should read ‘ignore_sticky_posts’ => … Read more

Latest Sticky Posts with Grid Thumbnails for static front page

I found it. <div class=”trending-right”> <?php $sticky = get_option( ‘sticky_posts’ ); // Get all sticky posts rsort( $sticky ); // Sort the stickies, latest first $sticky = array_slice( $sticky, 0, 6 ); // Number of stickies to show query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1 ) ); // The query if (have_posts() ) { … Read more

Make sticky post with FacetWP

Ok, I figured it out myself. So maybe I can help someone out with the same question. I made a custom field TRUE / FALSE called “featured”. In facet WP I created this query: <?php return array( ‘post_type’ => ‘custom_post_type’, ‘post_status’ => ‘publish’, ‘meta_query’ => array( ‘is_featured’ => array( ‘key’ => ‘featured’, ‘compare’ => ‘EXISTS’ … Read more