Forum Moderators: open
<?php
query_posts('category_name=videos&orderby=date&order=desc&showposts=3');
while (have_posts()) {
the_post();
echo get_the_content(); // a YouTube embed code, for example
}
?>
SELECT wp_posts.ID, wp_posts.post_date_gmt, wp_posts.post_title, wp_posts.post_excerpt, wp_posts.post_status, wp_posts.post_type, wp_postmeta.meta_value FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'post' AND wp_posts.post_status = 'publish' AND wp_posts.post_date_gmt <= '".date('Y-m-d')." 00:00:01' GROUP BY wp_posts.ID ORDER BY wp_posts.post_date_gmt asc LIMIT 1
Would I still need to change my html page to php for your code to work? Also, can I use it exactly liek you have pasted into the post or would I need to change anything?
date('Y-m-d')." 00:00:01 bit. <?php // connect to the database here, and then... $query = "SELECT wp_posts.ID, wp_posts.post_date_gmt, wp_posts.post_title, wp_posts.post_excerpt, wp_posts.post_status, wp_posts.post_type, wp_postmeta.meta_value FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'post' AND wp_posts.post_status = 'publish' AND wp_posts.post_date_gmt <= '".date('Y-m-d')." 00:00:01' GROUP BY wp_posts.ID ORDER BY wp_posts.post_date_gmt asc LIMIT 4"; $returns = mysql_query($query); while ($result = mysql_fetch_row($returns)) { echo '<h2>'.$result[2].'</h2>'; echo '<p>'.$result[3].'</p>'; } ?>