I'm trying to use a predefined variable (generated from an earlier sweep of the database) in wordpress' standard get_permalink( get_page_by_title) function.
I'm assuming that this is possible? But I can't get it working, it always returns the url of the current page.
For the sake of clarity below I'm just manually assigning the variable.
<?php $mypagename = "My First Page"; ?> <a href="<?php echo esc_url( get_permalink( get_page_by_title( $mypagename ) ) ); ?>">LINK</a>
N.B - My First Page (my-first-page) does exist in the database
Any ideas where I'm going wrong or if it's not possible to do it like this do you have any other suggestions?