This may be what you want:
$args = array(
'posts_per_page' => 5,
'orderby' => 'rand'
);
$my_query = new WP_Query($args);
while ( $my_query->have_posts() ) : $my_query->the_post() ?>
<div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">
<div class="post-content">
<div class="video-content" align="center">
<?php
video_blog_function('450','366',get_the_ID());
?>
</div>
Thread Starter
Nwahs
(@nwahs)
vtxyzzy, thanks, the code seems right but I’m having trouble inserting it into the index.html. Whenever I do that I’ll either get an error message, or the code will show up on the page, above the video boxes. This is how I am trying to insert it:
<?php while ( have_posts() ) : the_post() ?>
$args = array(
'posts_per_page' => 5,
'orderby' => 'rand'
);
$my_query = new WP_Query($args);
while ( $my_query->have_posts() ) : $my_query->the_post() ?>
<div class="post-content">
<div class="video-content" align="center">
<?php
video_blog_function('450','366',get_the_ID());
?>
</div>
Any suggestions on how to insert it so it works? Thanks
You have 2 while loops – you only need one. Please post the full index.php at wordpress.pastebin.ca and post the link here so we can see the full program.
Thread Starter
Nwahs
(@nwahs)
Here is the full URL for the index.php page for the site.
http://wordpress.pastebin.ca/1818612
Thanks
OK, I have updated the code as well as I can. You have a lot of code at the front of the file that really belongs in header.php: there should not be any < html >, < head >, < body >, </ html >, </ head >, </ body > tags or content in index.php. All of the opening tags should already be in header.php. The closing head tag should be in header.php and the closing body and html tags should be in footer.php.
Until all of that is cleaned up, there is not much more I can do if any errors are still in index.php.
Thread Starter
Nwahs
(@nwahs)
I got read of any head, body, or HTML tags…they came with some code that I had pasted in there and I forgot to remove them. Here is the updated index.php:
http://wordpress.pastebin.ca/1819983
Here is a modified (hopefully corrected) version:
http://wordpress.pastebin.ca/1820031
Thread Starter
Nwahs
(@nwahs)
I’m getting this error when reloading the site with the modified index.php:
Parse error: syntax error, unexpected T_ENDWHILE in /home/mspdjcom/public_html/idol/wp-content/themes/videotheme/index.php on line 90
Thread Starter
Nwahs
(@nwahs)
I nailed down the right code. It seems as though I had to enter:
<?php query_posts($query_string . '&orderby=rand') ?>
before my wp loop. Now all my posts on my main page (index.php) are displayed in a random order upon load.
Thanks for your help vtxyzzy, couldn’t have realized this was right w/out your help!