So I want to get the permalink title of a new published post.
example “http://myblog.com/healthy-life.php” I need healthy-life.php
here is code I have but it gets me http://myblog.com/healthy-life.php
function get_laterst_post_url() {
global $wpdb;
$query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 1;";
$result = $wpdb->get_results($query);
if(is_object($result[0])) {
return get_permalink($result[0]->ID);
} else {
return '';
};
}
You could add:
But its always best to use wordpress functions to get links. Say: