【发布时间】:2020-01-15 07:05:50
【问题描述】:
我正在一个名为“库”的帖子类型模板上显示地图。这是我当前代码的“部分”:
if($map_key && is_singular( 'libraries' )) {
wp_enqueue_script('gmap', 'https://maps.googleapis.com/maps/api/js?key=' . $map_key);
}
现在我添加了另外 2 种帖子类型 - “餐厅”和“酒吧”,因此我还需要为这些单个帖子模板启用地图。
一开始我是这样做的:
if($map_key && is_singular( 'libraries', 'restaurants', 'bars' )) {
wp_enqueue_script('gmap', 'https://maps.googleapis.com/maps/api/js?key=' . $map_key);
}
但这似乎不起作用。
我怎样才能做到这一点?
【问题讨论】:
-
is_singular(['libraries', 'restaurants', 'bars'])?
标签: php arrays wordpress if-statement