I want to display the thumbnail of a post. If the user clicks the thumbnail he gets directed to that post. But when clicking it I get a 403 ERROR. I’m new to php what is wrong?
PHP
<?php
query_posts('cat=5');
while (have_posts()) : the_post();
the_title();
echo '<a href="<?php the_permalink();?>">';
the_post_thumbnail();
echo '</a>';
endwhile;
?>
Displays the URL for the permalink to the post currently being processed in The Loop. This tag must be within The Loop, and is generally used to display the permalink for each post, when the posts are being displayed. Since this template tag is limited to displaying the permalink for the post that is being processed, you cannot use it to display the permalink to an arbitrary post on your weblog. Refer to get_permalink() if you want to get the permalink for a post, given its unique post id.
http://codex.wordpress.org/Function_Reference/the_permalink
Your function is never interpreted, it’s considered as text, you could write:
just replace your code
TO :
your code will be :
I think it may be your syntax.
Try changing:
echo '<a href="<?php the_permalink();?>">';
to:
echo '<a href="';
the_permalink();
echo '"';
The reason being that you are trying to reinitialize php even though you must have already started the syntax if you are using echo. So you do not need
<?php ?>
Here is another forum for reference.
You have mistake in this section:
Replace that line on this:
And don’t use short echo
<?=...?>
, it can be turned off by your hosting provider.the_permalink()
function already haveecho
, so you should not put secondecho
.