這是HTML渲染線:空的空間,我怎麼可以做的更好
<a href='http://www.1stheme.dev/?frontiles=1946'>
<article class="post-1946 frontiles type-frontiles status-publish hentry Width_1_Height_1 " style="width:326px;height:326px;text-align:left;"
id="post-1946">
<header>
<p class="counter">1 </p>
<h2 style="">
Title </h2>
<h4 style="">
</h4>
</header>
<div class="frontile_hover Width_1_Height_1"
style="width:326px;height:326px;" id="post-1946">
</div>
</article>
</a>
的,這是生成它們的PHP:
<?php echo "<a href='"; if ($disable_link) {
echo "#' style='cursor:default'>";
} elseif ($custom_link) {
echo $custom_link . "'>";
} else {
echo $acf_permalink . "'>"; }
?>
<article <?php post_class($tile_dimension . ' ' . $shape); ?>
style="<?php
if ($invisible_tile) {echo "visibility:collapse" . ";";}
if ($custom_tile_width) {echo "width:" . $custom_tile_width . "px;";}
if (!$custom_tile_width && $tiles_units_width && $GLOBALS['acf_grid_width']) {
$custom_tile_width = $tiles_units_width * $GLOBALS['acf_grid_width'] + $GLOBALS['acf_grid_margin'] * ($tiles_units_width -1);
echo "width:" . $custom_tile_width . "px;";}
if ($custom_tile_height) {echo "height:" . $custom_tile_height . "px;";}
if (!$custom_tile_height && $tiles_units_height_ && $GLOBALS['acf_grid_height']) {
$custom_tile_height = $tiles_units_height_ * $GLOBALS['acf_grid_height'] + $GLOBALS['acf_grid_margin'] * ($tiles_units_height_ -1);
echo "height:" . $custom_tile_height . "px;";}
if ($text_font_alignment) {echo "text-align:" . $text_font_alignment . ";";}
if ($background_color || $background_image) {
echo "background:" . $background_color . " url(" . $background_image . ") center/cover;";}
?>"
id="post-<?php the_ID(); ?>">
<?php if (!$invisible_tile) : ?>
<header>
<p class="counter"><?php echo $wp_query->current_post +1; ?> </p>
<?php // the_post_thumbnail('', array('class' => 'th')); ?>
<h2 style="<?php
if ($title_font_color) {echo "color:" . $title_font_color . ";";}
if ($title_font_size) {echo "font-size:" . $title_font_size . ";";}
if ($title_margin) {echo "margin:" . $title_margin . ";";}
if ($title_font_family) {echo "font-family:" . $title_font_family . ";";}
if ($title_line_height) {echo "line-height:" . $title_line_height . ";";}
if(is_array($title_font_style) && in_array('bold', $title_font_style)) {
echo "font-weight:bold;"; }
if(is_array($title_font_style) && in_array('italic', $title_font_style)) {
echo "font-style:italic;"; }
if ($title_letter_spacing) {echo "letter-spacing:" . $title_letter_spacing . ";";}
?>">
<?php if ($alternative_title) {echo $alternative_title;} else {the_title();} ?>
</h2>
<h4 style="<?php
if ($desc_font_color) {echo "color:" . $desc_font_color . ";";}
if ($desc_font_size) {echo "font-size:" . $desc_font_size . ";";}
if ($desc_margin) {echo "margin:" . $desc_margin . ";";}
if ($desc_font_family) {echo "font-family:" . $desc_font_family . ";";}
if ($desc_line_height) {echo "line-height:" . $desc_line_height . ";";}
if(is_array($title_font_style) && in_array('bold', $title_font_style)) {
echo "font-weight:bold;"; }
if(is_array($title_font_style) && in_array('italic', $title_font_style)) {
echo "font-style:italic;"; }
if ($desc_letter_spacing) {echo "letter-spacing:" . $desc_letter_spacing . ";";}1
?>">
<?php if ($alternative_desc) {echo $alternative_desc;} else {the_excerpt();} ?>
</h4>
</header>
<?php if (!$disable_on_over) : ?>
<div class="frontile_hover <?php echo $tile_dimension ?>"
style="<?php
if ($hover_bkg_color || $hover_bkg_img) {
echo "background:" . $hover_bkg_color . " url(" . $hover_bkg_img . ") center/cover;";}
if ($custom_tile_width) {echo "width:" . $custom_tile_width . "px;";}
if (!$custom_tile_width && $tiles_units_width && $GLOBALS['acf_grid_width']) {
$custom_tile_width = $tiles_units_width * $GLOBALS['acf_grid_width'] + $GLOBALS['acf_grid_margin'] * ($tiles_units_width -1);
echo "width:" . $custom_tile_width . "px;";}
if ($custom_tile_height) {echo "height:" . $custom_tile_height . "px;";}
if (!$custom_tile_height && $tiles_units_height_ && $GLOBALS['acf_grid_height']) {
$custom_tile_height = $tiles_units_height_ * $GLOBALS['acf_grid_height'] + $GLOBALS['acf_grid_margin'] * ($tiles_units_height_ -1);
echo "height:" . $custom_tile_height . "px;";}
?>" id="post-<?php the_ID(); ?>">
<?php echo the_excerpt(); ?>
</div>
<?php endif; // end disable_on_mouse over?>
<?php endif; // end invisible_tile?>
</article>
</a>
此代碼作品,但它呈現了太多的空白。 歡迎任何幫助。
我沒有太多的話要說,我使用高級自定義字段與wordpress建立一個可定製的主題。對不起所有的代碼,但以這種方式,你可以更好地檢查我認爲。
使用鍵盤上的Enter鍵將空白符合您的喜好。 – 2014-10-11 23:19:45
如果你在PHP中斷行,它將在源代碼中顯示換行符。 HTML將多個空格和換行符視爲單個空格,而不是由'
'創建的空格和換行符。如果我想要漂亮的源代碼,我通常將所有內容連接到一個變量,然後再回顯。 – PHPglue 2014-10-11 23:25:32