I am trying to get post title by sql. My sql code is
$query ="SELECT wp_posts.post_title AS title ,
wp_posts.post_content AS content,
wp_posts.post_date AS blogdate
FROM wp_posts
WHERE wp_posts.post_status="publish"
ORDER BY wp_posts.post_date DESC ";
global $wpdb;
$result= $wpdb->get_results($query);
if ($result){
foreach($result as $post){
?><li><a href="https://wordpress.stackexchange.com/questions/257892/<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php echo $post->title; ?></a></li><?php
}
}else{
echo "Sorry, No Post Found.";
}
die();
Now the problem is I am getting title but the_permalink() is not working.