Created
May 22, 2012 04:59
-
-
Save jo-snips/2766720 to your computer and use it in GitHub Desktop.
The Events Calendar: tribe_get_events() w/Transient API
This file contains hidden or 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
| <?php | |
| // Get any existing copy of our transient data | |
| if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) { | |
| // It wasn't there, so regenerate the data and save the transient | |
| $randargs = array('orderby' => 'rand', 'numberposts' => 20); | |
| $special_query_results = tribe_get_events($randargs); | |
| set_transient( 'special_query_results', $special_query_results, 60*60*12 ); | |
| } | |
| // Use the data like you would have normally... | |
| $randomposts = get_transient( 'special_query_results' ); | |
| $randkey = array_rand( $randomposts, 6 ); | |
| $sixposts[0] = $randomposts[$randkey[0]]; | |
| $sixposts[1] = $randomposts[$randkey[1]]; | |
| $sixposts[2] = $randomposts[$randkey[2]]; | |
| $sixposts[3] = $randomposts[$randkey[3]]; | |
| $sixposts[4] = $randomposts[$randkey[4]]; | |
| $sixposts[5] = $randomposts[$randkey[5]]; | |
| global $post; | |
| foreach( $sixposts as $post ) : setup_postdata($post); ?> | |
| <div class="gridcontainer"> | |
| <div class="gridthumb"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div> | |
| <div class="gridcontent"> | |
| <div class="gridtext"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div> | |
| </div> | |
| </div> | |
| <?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment