【发布时间】:2019-05-19 22:40:09
【问题描述】:
我想在不同的页面上显示不同的幻灯片
我想我需要使用 if elseif else PHP 循环,但语法不正确
这是我的代码:
<?php if( is_front_page() ) : ?>
<div class="mobile-header"> <img src="/images/mobile-header.jpg" width="1080" height="1000" alt="Sean Sheehan" /> </div>
<?php if ( function_exists( 'soliloquy' ) ) { soliloquy( 'homepage-dark', 'slug' ); } ?>
<?php else : ?>
<header id="masthead" class="<?php echo is_singular() && twentynineteen_can_show_post_thumbnail() ? 'site-header featured-image' : 'site-header'; ?>">
每当我尝试添加 elseif 时,代码就会中断。我尝试这样做以在第 25 页上显示不同的滑块:
<?php if( is_front_page() ) : ?>
<div class="mobile-header"> <img src="/images/mobile-header.jpg" width="1080" height="1000" alt="Sean Sheehan" /> </div>
<?php if ( function_exists( 'soliloquy' ) ) { soliloquy( 'homepage-dark', 'slug' ); } ?>
<?php elseif ( is_page(25) ) {
?>
<div class="mobile-header"> <img src="/images/mobile-header.jpg" width="1080" height="1000" alt="Sean Sheehan" /> </div>
<?php if ( function_exists( 'soliloquy' ) ) { soliloquy( 'photography-dark', 'slug' ); } ?>
<?php else : ?>
<header id="masthead" class="<?php echo is_singular() && twentynineteen_can_show_post_thumbnail() ? 'site-header featured-image' : 'site-header'; ?>">
但是这段代码不正确。
【问题讨论】:
-
请提供更多详细信息,例如代码如何中断:您看到了哪些错误消息?
-
解析错误:语法错误,意外'{',期待':'在/homepages/4/d554888208/htdocs/sean/wp-content/themes/twentynineteen-child/header.php 在线61