Get a free trial // Grow your CSS skills // Land your dream job

Check if a URL is live for conditional statement

  • # November 10, 2012 at 5:23 pm

    Is there a way to check to see if a link goes to a valid page?

    I have code that I only want displayed if the link that is surrounding it is valid.

    I am in WordPress, if that matters. And I thought is_wp_error() might be the way to go, but it’s not working.

    Hope I’m explaining this well enough. Here’s my code:

    $practice_rep_link = “$practice_link-rep/”;
    if (!is_wp_error($practice_rep_link)) {
    echo ‘

    Representative Cases’.’


    # November 11, 2012 at 4:37 pm

    Yeah, I’d tried that previously. It doesn’t seem to work for me. It tells me a page exists when it definitely doesn’t. Could it be because I have a custom 404 page?

    # November 11, 2012 at 5:05 pm

    @slb535 Possibly.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed