get_permalink
doesn’t output anything, it return
s the permalink. Your first call works because you use it within the_title
, which echo
s its value along with any before
and after
parameters you pass to it.
Change your second instance to:
<?php echo get_permalink(); ?>
or use the_permalink
, which echo
s the value instead of return
ing.
<?php the_permalink(); ?>
Many functions within WordPress follow this same pattern, get_
vs. the_
, one returns for use within php, one prints to page.