Php 如何将多个模板添加到if is_页面_模板中?
我必须在此代码中添加多个模板条件:Php 如何将多个模板添加到if is_页面_模板中?,php,wordpress,Php,Wordpress,我必须在此代码中添加多个模板条件: if ( is_page_template( 'single.php' ) ) { wp_enqueue_script( 'google-maps-infobox', get_template_directory_uri() . '/js/gmap3.infobox.js', array( 'jquery' ), '225', true ); wp_enqueue_script( 'google-maps-infobox2', get_template_dir
if ( is_page_template( 'single.php' ) ) {
wp_enqueue_script( 'google-maps-infobox', get_template_directory_uri() . '/js/gmap3.infobox.js', array( 'jquery' ), '225', true );
wp_enqueue_script( 'google-maps-infobox2', get_template_directory_uri() . '/js/gmap3.infobox2.js', array( 'jquery' ), '225', true );
}
如您所见,我已经添加了single.php,但需要在这里添加template1.php、template2.php等等。我这样试过:
if ( is_page_template( 'single.php', 'template1.php', 'template2.php' ) ) {
wp_enqueue_script( 'google-maps-infobox', get_template_directory_uri() . '/js/gmap3.infobox.js', array( 'jquery' ), '225', true );
wp_enqueue_script( 'google-maps-infobox2', get_template_directory_uri() . '/js/gmap3.infobox2.js', array( 'jquery' ), '225', true );
}
不幸的是,这不起作用。我如何编辑此文件以使用这些模板将WordPress页面的多个脚本编入队列
关于应该是这样的:
if ( is_page_template( 'single.php' ) || is_page_template( 'template1.php' ) || is_page_template( 'template2.php' )) {
//your code goes here
}
希望这对你有用。谢谢,它帮了我很多忙!