We are away from the office until 18th October, 24. Our support system is closed now.

Premium add-on for Bricks Builder

How to get the posts of the current post author

Get similar posts from the current post author

Bricks added the Query Loop builder and I want to add the more posts section of the current post’s author inside the author box with the help of that query loop builder feature.

Step 1: Add the container and enable the “Use Query Loop” option.
Step 2: Under the “Query” control I configured the following options:

a) Type: Posts
b) Post Type: Posts
c) Posts Per Page: 5
d) Enable “Exclude Current Post” option

If you want, you can add more options as per your requirements.

Step 3: Open the functions.php file of the bricks child theme and add the following PHP code.

add_filter( 'bricks/posts/query_vars', 'bu_get_posts_post_author', 12, 3 );
function bu_get_posts_post_author( $query_vars, $settings, $element_id ) {
	/** 
	 * pilbnn is my query loop builder's container ID.
	 * You will change it with yours one
	 * 
	 * So this code will not apply to entire site
	 */
	if( $element_id == 'pilbnn' ) {
		global $post;
		$query_vars['author'] = $post->post_author;
	}

	return $query_vars;
}
Element ID
Element ID

After adding the code, go to the builder editor and reload the builder editor. Now you will select that container and add the nested elements like post title, metadata, etc. My structure was like this

More posts from the current post author
Structure panel

All steps are completed here.

Fills In: 

Leave the first comment

Search Tutorials

Request TutorialsFeatures Request