Hi @jkgartzia,
Cool idea, I’m very curious to see the result of this!
For the old (pre-1.0) version, I published a code-snippet to do exactly this: https://gist.github.com/mgmartel/4454318
You can see how it works on http://createdbydanielle.com
However, when using WP Tiles 1.0 this doesn’t work any more. Now, you should modify the WP_Query object directly and render the tiles in the PHP template. I still have to make a new gist for WP Tiles 1.0, but here is the basic outline:
// 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 );
Let me know how it works out!
Cheers,
Mike
Please can you tell me how this should work?
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?
Thanx Mwalima
Achieve run the above code,
but I can not take me the $args
How can i put the args?
Placed them in this way:
// WP Tiles arguments $args = array( 'grids' => News );
Btu dosen´t work.
The full code is this:
<?php //if ( function_exists ( 'the_wp_tiles' ) ) the_wp_tiles( ); $query = new WP_Query(array( 'post_type' => 'post', 'posts_per_page' => 13, '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( 'grids' => News );
// Display the tiles the_wp_tiles( $query, $args );
?>
And the demo: http://infomedia24.esy.es/
“About 1” and “Blog 4” are pages, the others are posts.
The same as above, but better lecture.
<?php
$query = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 13,
'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(
'grids' => News
);
// Display the tiles
the_wp_tiles( $query, $args );
?>
Hi @3551,
The $args contains all WP Tiles arguments. They are generally the same as the shortcode, just marked up as a PHP array. See the documentation on the template tags here.
In your snippet, there is a syntax error in the arguments – you need to put quotes around the grid name:
// WP Tiles arguments
$args = array(
'grids' => News
);
Cheers,
Mike
Hi Mike Martel,
Please can you tell me how this should work?
I want to paste php code with wp_tiles on my site
I have wordpresss 4.1 installed and the latest version of wp_tiles.
I want to have some tiles like this one grid:
AACB
DDEB
and I want fill them with specified content (specified category of posts).
But I can’t edit the code above.
How should it be written (the code) ?
Please can you help me?
Thanx
Cinek