Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get first post link in Wordpress
function get_first_post_link() {
global $wpdb, $table_prefix;
$result = $wpdb->get_row("select * from {$table_prefix}posts where post_type = 'post' and post_status = 'publish' ORDER BY `{$table_prefix}posts`.`ID` ASC LIMIT 1");
if($result) {
return get_permalink( $result->ID );
echo get_first_post_link();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.