StinkyJoe
StinkyJoe

Reputation: 1

Internal link in WordPress footer.php file not working

I am creating a child theme and I have added a link in the footer.php file to a page within my website. I used the WordPress recommended:

<a href="<?php echo esc_url( get_permalink( get_page_by_title( 'PAGE TITLE' ) ) ); ?>">PAGE TITLE</a>

which displays the proper URL when the link is clicked, but I get a 404 error. I determined that if I set my permalink setting to Default it will bring up the page, but the URL is the permalink ID, not the slug. I want to use Post name for my permalinks for SEO purposes. Any suggestions?

Upvotes: 0

Views: 455

Answers (1)

Cleanshooter
Cleanshooter

Reputation: 2375

With out seeing what the resulting URL is it's hard to say what the problem is. I'm guessing you're using the example here on the get_permalink() function page. My guess is that you simply don't need to use the esc_url() function. According to Stephen Harris get_permalink() performs it's own sanitation so using esc_url() on it is not necessary despite it being "recommended" on the codex.

It would be more helpful if you posted a link to your page or at least the resulting code.

Upvotes: 1

Related Questions