Skip to content

Instantly share code, notes, and snippets.

@seancojr
Forked from mgmartel/wp-tiles-menu.php
Created April 7, 2014 03:25
Show Gist options
  • Save seancojr/10014408 to your computer and use it in GitHub Desktop.
Save seancojr/10014408 to your computer and use it in GitHub Desktop.
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment