<?php the_permalink(); ?>
in the echo, so when the post title is clicked it opens it is respective post link, but on click of post title it is opening this link http://localhost/courses/, Here is my code
echo '<p><a href="<?php the_permalink(); ?>">'.$post->post_title.'</a></p>';
3
Answers
This code is working, Thankyou
You are declaring PHP code within PHP code. Remove
<?PHP ?>
declaration tags, as they are not needed, and replace with string combine which is.
in PHP.End result should be:
As mentioned in the other answer, get_permalink() should be used, as it returns not echos. the_permalink() echos the return.
The problem is
the_permalink
.As a general rule (not always correct),
the_
will echo,get_
will return.So in your case change
the_permalink()
toget_permalink()