我正在用WordPress建立网站。有些页面带有标题横幅,有些则没有。
在header.php文件中,我插入了以下代码:
<div class="featured-image">
<?php if ( has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
<?php if ( is_front_page()): ?>
<span class="home-header-title"><h1><?php echo event_title(); ?></h1></span>
<span class="tag-line"><?php the_field('tag_line'); ?></span>
<span class="date-time-header"><?php the_field('date_time_header'); ?></span>
<?php $ticket = get_field('ticket_url');
if( $ticket ):
$ticket_url = $ticket['url'];
$ticket_title = $ticket['title'];
?>
<a class="ticket-banner-button" href="<?php echo esc_url($ticket_url); ?>"><?php echo esc_html($ticket_title); ?></a>
<?php endif; ?>
<?php else: ?>
<span class="page-header-title"><h1><?php the_field('page_header'); ?></h1></span>
<span class="sub-header"><?php the_field('sub_header'); ?></span>
<?php endif;?>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.page-header-title h1 {
font-weight: bold; …Run Code Online (Sandbox Code Playgroud)