View Single Post
Old 05-17-2013, 08:50 AM  
madtwin
Confirmed User
 
Industry Role:
Join Date: Aug 2009
Posts: 274
Shit... I can't get it work

I have standard query on index.php like this:

Quote:
<?php if(have_posts()) { ?>

<?php while (have_posts()) : the_post(); ?>

<div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_titile(); ?></a>
</div>

<?php endwhile; ?>
So where goes all the Transients API stuff? Something like this?

Quote:
<?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' => 10);
$special_query_results = get_posts($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' );

global $post;
foreach( $randomposts as $post ) : setup_postdata($post); ?>

<div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_titile(); ?></a>
</div>

<?php endforeach; ?>
When using this code I get blank page...

madtwin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote