0
我有這個代碼從WordPress的如果類空返消息
global $post;
$i=0;
$args = array('numberposts' => 5, 'category' =>5,'order'=>'DESC','orderby'=>'post_date','suppress_filters' => 0);
$myposts = get_posts($args);
$has_posts = true;
foreach($myposts as $post) : setup_postdata($post); ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?>
<li>
<?php if($image){ ?>
<div class="news_left"><a href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" alt="" width="191" height="132" /></a></div>
<?php } ?>
<?php
$content = apply_filters('the_content', get_the_content());
$content = explode("</p>", $content);
?>
<div class="news_right">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<span class="date">Date: <?php the_time('j/m/Y') ?></span>
<?php echo $content[1] . "</p>";//echo String::content_limit(200,'<p>'); ?>
<a href="<?php the_permalink(); ?>">Read More</a>
</div>
<div class="clear"></div>
</li>
<?php $i++; endforeach; ?>
一些內容我需要把狀態返回文本消息,如果類是empty.like沒有文章顯示,請注意後使用WPML的語言切換器
很抱歉,但我是新來的,更多地解釋:d – user1714777
@ user1714777我已經更新了代碼 –
THX這麼多的工作就像一個魅力:) – user1714777