2018-06-29, 20:12:35
(This post was last modified: 2018-06-29, 20:14:09 by VIPStephan.)
I have a simple website with a pretty static menu (not using the get_navigation function for reasons). Now, I would like to add a preliminary link that is automatically hidden if the page isn’t existing yet, and once the page is created it will be visible. How can I do this? Something like:
And also, independent of this: is there a way to retreive page URLs dynamically? Currently I’m doing something like
where the page slug is “example”. But what if my site settings are changed, for example, to add a different extension to pages via mod_rewrite? I’d like something where the correct URL is output automatically; I’m imagining something like “get_permalink('example')” where it would print either “index.php?id=example” or “example.php” or whatever, depending on the permalink settings. Is this possible?
PHP Code:
<?php if(page_exists('example')) { ?>visible only if the page with the slug “example” exists<?php } ?>
And also, independent of this: is there a way to retreive page URLs dynamically? Currently I’m doing something like
PHP Code:
<a href="<?php get_site_url(); ?>example">Example</a>