• I would like to create a link in the header based upon whether or not a particular page exists.

    Is there a query function that can determine if a page exists based up title, slug or id?

Viewing 5 replies - 1 through 5 (of 5 total)
  • By using condtional tags.
    Conditional_Tags#A_PAGE_Page

    Thread Starter hokie99cpe

    (@hokie99cpe)

    But, correct me if I am wrong, that tells you if the current URL is a page.

    For example, user brings up https://blogserver/. If I check is_page(‘contact’), that will fail because / is not (likely) the page named ‘contact’.

    Here’s the whole story:

    The theme displays the admin email for a “contact” link. But, some blogs on my system use the “WP-ContactForm” plugin. I have them setup to use a page named “Contact” to display this contact page. So, what I want to do: if the blog loading has a “Contact” page, create the contact link to that page rather than an email address.

    It would be nice if WP had an “if page exists” or a similar function built-in. I am looking for a way to incorporate a certain feature into some of my themes if a page exists matching entries in a set list of slugs.

    <?php if(get_page_by_title('Page Title')) : ?>
    [do stuff]
    <?php endif;?>

    <?php if(get_page_by_title(‘Page Title’)) : ?>
    [do stuff]
    <?php endif;?>

    this is wonderful… it helped me as well, thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Find if page exists?’ is closed to new replies.