Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将多个模板添加到if is_页面_模板中?_Php_Wordpress - Fatal编程技术网

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
}

希望这对你有用。

谢谢,它帮了我很多忙!