Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION condition: if page exists, show link
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:

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
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?
1. A couple ways to do it, here:

2. Example function here:

Users browsing this thread: 1 Guest(s)