On the site I'm working now on there's a number of links hardcoded into templates, such as
- Privacy and cookies
- Registration policy
- Search help
and so on.
The pages that are linked to these don't have any special design, they just inherit the default page layout.
The project I'm working on uses GIT and a workflow with multiple environments (several locals for different developers, staging, production). On all of those DBs usually are completely independent and non shared or synchronized.
What is the best way to link to these pages on frontend? I've thought about three options for now of which I'm currently using the latter one.
- If I hardcode links to them just by referencing an ID of a page (via
get_permalinkfor example) then on staging the ID might not be the same and the link will be broken. Also the page is not reassignable which might not be good.
- If the project uses some kind of custom fields plugin like ACF or Metabox.io we might use that to create global fields per each link to allow editors to reassign them.
- The pages can be linked via creating a custom template and then retrieving the link to the first page (thanks to
'meta_key' => '_wp_page_template'WP_Query parameter) that uses this template. This solution is not optimal because it spams the project with potentially increasing number of duplicate templates that are all empty and don't serve any meaningful function as a part of theme.
So the question is, is there a better way to do the same thing in a native and flexible manner? Has somebody had experience solving the same problem?