mardi 14 janvier 2020

Wordpress - If Statement function - multiple post types

I'm showing a map on a single post type template called 'libraries'. Here is the 'part' of my current code:

if($map_key && is_singular( 'libraries' )) {
        wp_enqueue_script('gmap', 'https://maps.googleapis.com/maps/api/js?key=' . $map_key);
}

Now I added additional 2 post types - 'restaurants' and 'bars' and so I also need enable the map for these single post templates.

Initially I went with this:

if($map_key && is_singular( 'libraries', 'restaurants', 'bars' )) {
        wp_enqueue_script('gmap', 'https://maps.googleapis.com/maps/api/js?key=' . $map_key);
}

But that doesn't seem to work.

How can I make this work?

Aucun commentaire:

Enregistrer un commentaire