I”m trying to get the block of code below to load only when it’s the contact page but it doesn’t seem to wotk. Any ideas what the problem could be. Still pretty much new to PHP.

if (is_page('/contact-us/')) {
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
        wpcf7_enqueue_scripts();
        wpcf7_enqueue_styles();
    }
}

1 Answer
1

The is_page function accepts any of the page ID, the page title or the page slug. It looks like you’re trying to give it an URL fragment instead.

You say that ‘contact-us’ is the page slug for your contact page, so try

if (is_page('contact-us')) {

without the forward slashes, i.e. passing the page slug, instead.

Leave a Reply

Your email address will not be published. Required fields are marked *