Fixed Tiles to static position in Grid
-
Please can you tell me how this should work?
Query all the posts (your normal WP Tiles query goes here)
$query = new WP_Query(array(
‘post_type’ => ‘post’,
‘posts_per_page’ => 18,
‘paged’ => 1
) );// Query the pages that have a static position
$pages = get_posts( array(
‘meta_key’ => ’tile-position’,
‘post_type’ => ‘page’,
‘posts_per_page’ => 20
) );// Loop over the pages, check their position and put them there in the posts array
foreach ( $pages as $page ) {$position = get_post_meta( $page->ID, ’tile-position’, true );
if ( empty ( $position ) || ! is_numeric ( $position ) )
continue;// Magic happens here:
array_splice ( $query->posts, $position – 1, 0, array ( $page ) );
}// WP Tiles arguments
$args = array();// Display the tiles
the_wp_tiles( $query, $args );
I have wordpresss 4.1 installed and the latest version of wp_tiles.
I want to fix some tiles in certain positions and fill them with all kinds of content.I do not understand the above code. Can you explain in detail?
- The topic ‘Fixed Tiles to static position in Grid’ is closed to new replies.