我的h2標籤內的文本浮動到分區的頂部。我覺得我的眼睛可能會忽略一些東西,導致帖子的標題浮動到分區的頂部。不幸的是,我不能看到我輸出這個tite的另一個區域。文本移出標題標籤
這是我的HTML/PHP。我爲混亂而道歉。
<!-- locations page array -->
<?php $args = array('post_type' => 'weblizar_portfolio','posts_per_page' => -1);
$portfolio = new WP_Query($args);
if($portfolio->have_posts())
{ while ($portfolio->have_posts()) : $portfolio->the_post(); ?>
<div class="col-lg-4 col-md-4">
<!--<div class="img-wrapper">-->
<?php $defalt_arg = array('class' => "enigma_img_responsive");
$portfolio_button_link = get_post_permalink($sample);
$dates = get_post_meta(get_the_ID(), 'date', true);
$postTitle = the_title(); ?>
<?php if(!isMobile()){ ?>
<a href='<?php echo $portfolio_button_link; ?>'>
<div class="author-item">
<div class="imageItem">
<?php if(has_post_thumbnail()):
the_post_thumbnail('portfo_4_thumb', $defalt_arg);
$port_thumbnail_id = get_post_thumbnail_id();
$image_thumbnail_url = wp_get_attachment_url($port_thumbnail_id);
endif; ?>
</div>
<div class="author-info">
<!-- THIS IS THE AREA NOT WORKING -->
<h2><?php echo $postTitle; ?></h2>
<h4><?php echo $dates; ?></h4>
</div>
</div>
</a>
<?php } else { ?>
<table>
<a href='<?php echo $portfolio_button_link;?>'>
<tr>
<td>
<?php echo $postTitle;?>
</td>
<td>
<?php echo $dates; ?>
</td>
</tr>
</a>
</table>
<?php } ?>
這裏是執行HTML:
<div class="col-lg-4 col-md-4">
<!--<div class="img-wrapper">-->
San Jose <a href="">
<div class="author-item">
<div class="imageItem">
<img width="260" height="160" src="" class="enigma_img_responsive wp-post-image" alt="San Antonio" srcset="" sizes="(max-width: 260px) 100vw, 260px"> </div>
<div class="author-info">
<h2></h2>
<h4>April 23rd, 2016</h4>
</div>
</div>
</a>
<!--</div>-->
</div>
你應該用'get_the_title'替換'the_title'。原因是'the_title'只是立即迴應標題,並不會將任何內容返回給您的變量,這就是爲什麼它是空的。而'get_the_title'只是返回它。 –