This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Reply To: Tip: simulate post grid (for specific pages)

#1006
mharpen
Participant

I’ve modified your function (placed in the child theme functions.php) to allow passing a list of page or post ID’s in the query string of the post_grid shortcode. See example in comment:

/**
 * Custom query for post lists/post grids
 * Example shortcode to use: [post_grid query="show_ids=31,43" columns="2"]
 */
function my_custom_posts_query( $query, $args ){
	$lc1 = strstr($query, "show_ids=");
	if($lc1 != false) {
		$lc1 = strtok($lc1, "=");	
		$lc1 = strtok("&");	
		if($lc1 != false) {
			$query = array( 
				'post_type' => 'page', 
				'post__in' => explode(",", $lc1)
			);
		}
	}
	return $query;
}
add_filter( 'themeblvd_posts_args', 'my_custom_posts_query', 10, 2 );