Last active
June 2, 2016 13:48
-
-
Save ChrisFlannagan/82e07143624446c3cdccd29eb8bfa1ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div u="slides" style="cursor: move; position: absolute; overflow: hidden; left: 0px; top: 0px; width: 1090px; height: 550px;"> | |
<?php | |
$slides_trans = get_transient( "slides_rest_api"); | |
$allslides = array(); | |
if( !$slides_trans || $_REQUEST['reset_trans'] == 'please' ) { | |
// Best to use wp_remote_get here but for brevity in example we use file_get_contents | |
$callret = file_get_contents( site_url() . '/wp-json/posts?filter[category_name]=home-slides&filter[posts_per_page]=-1' ); | |
$allslides = json_decode( $callret, true ); | |
set_transient( "slides_rest_api", $callret, 60*60*12 ); | |
} else { | |
$allslides = json_decode( $slides_trans, true ); | |
} | |
$cnt = 0; | |
foreach ($allslides as $slide) { | |
$thumbnail_id = get_post_thumbnail_id($slide['ID']); | |
$thumbnail = wp_get_attachment_image_src($thumbnail_id, 'large'); | |
?> | |
<div data-idle="6500"> | |
<a href="<?php echo esc_url( $slide['link'] ); ?>"><img u="image" src='<?php echo $thumbnail[0]; ?>' /></a> | |
</div> | |
<?php | |
$cnt++; | |
} | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment