I am searching to retrieve probably the most lately released publish inside a wordpress system. I've some fundamental mysql understanding and that i will find in which the revisions are saved within the wordpress_posts table but things i can't appear to locate is how you can retrieve the permalink which are more recent publish.
any tips on how to retrieve the newest publish with mysql and permalink?
I see you will find some existing functions from Wordpress like so:
// get the latest blog entry $myposts = get_posts('numberposts=1'); foreach($myposts as $post) : echo '<a href="' . the_permalink() . '">' . the_title() . '</a>'; endforeach;
However when I put this on the custom page I am focusing on, it appears to simply be tugging the page title I am presently on and also the connect to this site (despite the fact that I am thinking the above mentioned function ought to be locating a 'post'.
What shall we be held missing?
Exercised the answer:
<?php global $post; // needed this // get the latest blog entry $myposts = get_posts('numberposts=1&orderby=date&order=DESC'); // and more stuff here foreach($myposts as $post) : ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php endforeach; ?>
Just just in case you might want to possess a real MySQL solution, this is what I personally use:
$query = "SELECT * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 1"; $post = mysql_fetch_assoc(mysql_query($query));
the $publish array holds all of the data regarding towards the latest publish.