esc_url :去掉 script標記
get_the_title() :取得標題
get_the_date('Y-m-d'):取得日期
$custom_query2->the_post(); 之後才能用
把日期加入frontpage (檔案名稱:frontpage.php)
1. $column增加date 於 tempera_ppcolumns() 函數的default段
while ($custom_query2->have_posts()) :
$custom_query2->the_post();
$img = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ),'columns');
$column['image'] = esc_url( $img[0] );
$column['link'] = esc_url( get_permalink() );
$column['text'] = get_the_excerpt();
$column['title'] = get_the_title() ;
$column['date'] = get_the_date('Y-m-d');
$columns[] = $column;
endwhile;
2.$coldata增加date 於 tempera_columns()
$coldata = array(
'colno' => (($counter%$nr_columns)?$counter%$nr_columns:$nr_columns),
'counter' => $counter,
'image' => esc_url( $column['image'] ),
'link' => esc_url( $column['link'] ),
'blank' => ($column['blank']?'target="_blank"':''),
'title' => wp_kses_data($column['title']),
'text' => wp_kses_data($column['text']),
'date' => $column['date'],
'readmore' => wp_kses_data($readmore),
);
3. 輸出於 tempera_singlecolumn_output() (檔案:includes/widget.php)
以 <div><?php echo $date; ?></div> 輸出
if ( ! function_exists('tempera_singlecolumn_output') ):
function tempera_singlecolumn_output($data){
foreach ($data as $key => $value) { ${"$key"} = $value; }
?>
<div class="pp-column column<?php echo $colno; ?>">
<?php if (!empty($image)) { ?>
<a href="<?php echo $link; ?>" <?php echo $blank; ?> class="clickable-column">
<?php if (!empty($title)) { echo "<h3 class='column-header-image'>".$title."</h3>"; } ?>
</a>
<?php
if (!empty($date)) {
echo "<div>{$date}</div>";
}
?>
<div class="column-image">
<div class="column-image-inside"> </div>
<a href="<?php echo $link; ?>" <?php echo $blank; ?> class="clickable-column">
<img src="<?php echo esc_url($image) ?>" alt="<?php echo (!empty($title)?wp_kses($title,array()):''); ?>" />
</a>
<?php if (!empty($text)) { ?>
<div class="column-text">
<?php echo $text; ?>
</div>
<?php } ?>
<?php if ( !empty($readmore) && !empty($link) ) { ?>
<div class="columnmore">
<a href="<?php echo $link; ?>" <?php echo $blank; ?>><?php echo $readmore ?> <i class="column-arrow"></i> </a>
</div>
<?php } ?>
</div><!--column-image-->
<?php } ?>
</div><!-- column -->
<?php
} // tempera_singlecolumn_output()
endif;
沒有留言:
張貼留言