Premium add-on for Bricks Builder

Display only sticky posts with the loop builder

In this tutorial, I shall show you how you will list the all sticky posts with the bricks loop builder. Make sure that you installed the BricksUltimate add-on and activate the Ultimate Query Builder option from your Dashboard -> Bricks -> BricksUltimate -> Misc tab. Now add one element of these container, block, and div elements to the canvas and enable the loop option. Select the Query -> Type -> Ultimate Query Builder -> Custom WP Query provider.

Drop the following PHP code in the code text box and create the post list layout with the help of the nested elements like image, post title, excerpt, button, etc.

<?php
$args   = array(
	'posts_per_page'      => -1,
	'post__in'            => get_option( 'sticky_posts' ),
	'ignore_sticky_posts' => 1,
);

return $args;

Get Top 5 Sticky Posts

<?php
/* Get all Sticky Posts */
$sticky = get_option( 'sticky_posts' );

/* Sort Sticky Posts, newest at the top */
rsort( $sticky );

/* Get top 5 Sticky Posts */
$sticky = array_slice( $sticky, 0, 5 );

$args   = array(
	'post__in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1,
);

return $args;

Exclude All Sticky Posts

If you want to exclude all sticky posts from the query, you can try this code:

<?php
$args   = array(
	'posts_per_page'      => 10,
	'post__not_in'        => get_option( 'sticky_posts' )
);
return $args;
Fills In: 

Leave the first comment

Search Tutorials

Request TutorialsFeatures Request