Inside my loop, I'm trying to have a link show and it won't I'm not sure why

Here is the code:

<?php the_title('<h2 class="wow"><a href="<?php the_permalink(); ?>"', '</a></h2>'); ?>

I understand this is maybe because of the '' quotations instead of "", but how would I achieve this general thing with just PHP and not by wrapping the_title(); in an a tag.

3 Answers 3


because the_title() expects a string for the $before and $after args, you need to use the string version of the permalink, in a string concatenation;

<?php the_title('<h2 class="wow"><a href="'.get_permalink().'">', '</a></h2>'); ?>

you also had a missing >.


  • I eventually found the answer elsewhere. THANK YOU. This is pretty much what the answer said to do. The only difference was that it escaped the permalink instead. Sep 27, 2017 at 22:48

You can't nest these functions. Change your code to

<h2 class="wow"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

23 seconds too late.

I think the issue is that you have a double open/close statement.

Without seeing your code, I would suggest you to edit your line of code as

<h2 class="wow"><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></h2>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.