【发布时间】:2014-01-03 07:44:08
【问题描述】:
我创建了名为“front-page.php”的自定义主页,然后在header.php 文件中添加了另一个带有自定义 css 和 JS 文件的页面:
<?php
function my_styles_method() {
if (is_page_template('front-page.php'==TRUE){
// Register the style like this for a theme:
wp_register_style( 'my-custom-style', get_template_directory_uri().'/includes/marquee.css');
// enqueue the stule
wp_enqueue_style( 'my-custom-style' );
}
enter code here
// Register the style like this for a theme:
if (is_page_template('our-story.php'==TRUE) {
wp_register_style( 'my-custom-style', get_template_directory_uri().'/includes/main.css');
// enqueue the stule
wp_enqueue_style( 'my-custom-style' );
}
}
add_action( 'wp_enqueue_scripts', 'my_styles_method' );
?>
现在,我面临以下问题: 当我在 WordPress 中运行它时,我收到以下错误消息:
解析错误:语法错误,意外的'{' in C:\wamp\www\wordpress_update\wp-content\themes\twentytwelve\header.php 在第 32 行
我在两个页面上都创建了自定义模板。
提前谢谢你。
【问题讨论】:
-
第 32 行附近发生了什么?
-
第 32 行是 if 语句 { 开始的地方..
-
so ...
if (is_page_template('front-page.php'==TRUE){你能发现错误吗? PS:第二次也是如此……
标签: javascript php html css wordpress