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: LInking from Post to Page?

#1821
Jason Bobich
Keymaster

This could be possible if you utilize the custom query option of a post grid. Here’s an answer from another topic I gave on this that you probably cannot read because you’re not a customer of that theme. So, I’ll paste the answer here.

=========

This is sort of tough to do from the custom query option because in all ways (that I know of anyway) to specify specific pages would not be possible within a single string.

I can think of two ways where actually feeding pages through to the post grid would be possible the way things are setup.

1) Take the pages you want to be in the post grid and set them as Child pages to some Parent page. Then in your custom query string you’d do this:

post_type=page&post_parent=123&numberposts=2

Where “123” is the numerical post ID for the Parent page, to which you want the child pages below it to show. Note that by using the custom query string in any post grid, you’re overriding the number of posts normally generated for you based on the columns/rows. So, you need to specify that, as well.

Reference: http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

2) Now, this is super hacky, but an interesting thing I just thought of. Internally, there is a filter on the query string every time a post grid is generated. But there’s no way to really identify this filter with a specific post grid instance.

In your instance of the Post grid, you could use the “query” option to pass in some unique identifier to use as a “catch” from your PHP function that you’re going to attach to the filter for all post grid queries.

So, for example, setup a post grid and for the query option write something like:

my_unique_key

Now from your Child theme’s functions.php you can filter onto the query string for all post grids and use that identifier to trigger some custom query string.

/**
 * Custom query for post lists/post grids
 */
function my_custom_posts_query( $query, $args ){
	if( $args['query'] == 'my_unique_key' ){
		$query = array( 
			'post_type' => 'page', 
			'post__in' => array( 1, 2, 3, 4 ) // ID's for any pages you want to include
		);
	}
	return $query;
}
add_filter( 'themeblvd_posts_args', 'my_custom_posts_query', 10, 2 );