How to echo a permalink in a conditional statement

Hi I hope you can help me with some advice.

I set up a website with a blog. The excerpts are shown on category.php
If there is content the excerpt is followed by a ‘read more’ link to the post. If there is nothing in content. It does not show ‘read more’

Read More

To show this link I’ve written the following piece of code.

<?php
global $post;

if ( empty( $post->post_content ) ) {
    echo '';
} else {
echo '<p class="laes-mere"><a href="<?php the_permalink(); ?>">L&aelig;s mere...</a>     </p>';
}
?>

The ‘read more’ (Læs mere…) shows up if there is content. This works exactly as I want it to. The problem is that the permalink does not work. I get this error

Not Found

The requested URL /< was not found on this server.

This is the page http://rubowarkitekter.dk/?cat=21
Any advice would be great. Thank you.

Ellen

Related posts

Leave a Reply

1 comment

  1. You have opened the php tags when php tags are already opened try this

    echo '<p class="laes-mere"><a href="'.the_permalink().'">L&aelig;s mere...</a>     </p>';
    

    You can also get the post link by using get_permalink

    echo '<p class="laes-mere"><a href="'.get_permalink( $post->ID).'">L&aelig;s mere...</a>     </p>';