快轉到主要內容

HowTo

Wordpress在循环LOOP中获取 post_date 使用自定义日期时间格式

Wordpress在循环LOOP中获取 post_date 使用自定义日期时间格式

·146 字·1 分鐘
code示例: 1<?php $args = array('numberposts' => '16','category' => '8'); 2 $recent_posts = wp_get_recent_posts( $args, ARRAY_A ); 3 foreach ($recent_posts as $recent) { 4 echo '<li><a href="'. get_permalink($recent["ID"]).'">'.$recent["post_title"].'</a><span class="list-meta">'. mysql2date('Y-m-d', $recent["post_date"]) .'</span></li>'; 5 } 6?> 原本直接用$recent['post_date']输出的是2014-11-11 14:30:24这样的格式,但现在不需要时间的输出,Y.Cheung 只需要输出日期,找了一下用mysql2date函数就可以。
獲取最新文章並附特色圖片的代碼

獲取最新文章並附特色圖片的代碼

·250 字·1 分鐘
幫朋友寫的,順便放在這裡mark一下好了。 以下代碼實現獲取最新10篇日誌及其100×100像素的特色圖片。 1<?php query_posts('posts_per_page=10'); if (have_posts()) : while (have_posts()) : the_post(); ?> 2 3<?php if (has_post_thumbnail()){the_post_thumbnail(array(100,100)); } ?> <?php the_title(); ?> 4 5<?php echo get_the_date(); ?> 6 7<?php endwhile; endif;?> COMMENTS (7) # 老武 · 2012-03-26T10:42:20+08:00
WordPress宕机一日

WordPress宕机一日

·616 字·2 分鐘
昨天突然无法访问我的blog了,还以为我又折腾什么出错了,却发现连服务器都进不去了。大件事啦! 联系了hugege(我在他那里租的主机),说是到国内的线路抽风喔。于是,我又定了定神,没事,等它抽完了就好了。果然,晚上的时候就恢复正常了,额,也不算太正常,时不时还是抽一下,不过,能访问就好了。(^U^)ノ~YO