public
Last active

Use WP Tiles as a site menu, by automatically adding pages on fixed locations in your website. Drop in your functions.php or functions plugin. It only shows pages with the meta value 'tile-position', which is their fixed position in the tiles.

  • Download Gist
wp-tiles-menu.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?php
add_filter( 'wp-tiles-data', 'fixed_page_tiles', 10, 4 );
function fixed_page_tiles( $data, $posts, $colors, $tiles_obj ) {
$pages = get_pages();
 
foreach ( $pages as $page ) {
$position = get_post_meta( $page->ID, 'tile-position', true );
if ( empty ( $position ) || ! is_numeric ( $position ) )
continue;
$tiledata = array (
"id" => $page->ID,
"title" => $page->post_title,
"url" => get_permalink( $page->ID ),
"category" => wp_get_post_categories( $page->ID, array ( "fields" => "names" ) ),
//"img" => $tiles_obj->get_first_image ( $page ),
"img" => get_stylesheet_directory_uri() . '/images/' . $page->post_name . '.png',
"color" => $colors[ array_rand( $colors ) ],
"hideByline" => true
);
array_splice ( $data, $position - 1, 0, array ( $tiledata ) );
}
return $data;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.