2012-01-16 85 views
0

我似乎無法使ger_ex_excerpt函數工作。wordpress the_excerpt不工作

這是我正在使用的代碼

我是不是調用循環的權利? 我沒有在我的functions.php中使用任何過濾器。

任何任何將是偉大的。

$col = 0; 
$col_count = 3; 
$cols = array(); 
// $my_query = new WP_Query('category_name=projects&posts_per_page=3'); 
// while ($my_query->have_posts()) : $my_query->the_post(); 
global $post; 
$args = array('numberposts' => 3, 'offset'=> 0, 'category_name' => 'projects'); 
$myposts = get_posts($args); 
foreach($myposts as $post) : setup_postdata($post); 
    if($col >= $col_count) $col = 0; 
    ob_start(); 
    ?> 
    <div class="post" id="post-'<?php the_ID(); ?>'"> 
    <span class="title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></span> 
    <div class="descr"><img src="<?php bloginfo('template_url'); ?>/lib/img/clock.png"> <?php the_time('F, jS'); ?>, <span class="author"><?php the_time('Y'); ?> by <?php the_author_posts_link() ?></span></div> 
    <div class="entry"> 
     <?php the_excerpt(); ?> 
    </div> 
    </div> 
    <?php 
    $output = ob_get_contents(); 
    ob_end_clean(); 
    $cols[$col++] .= $output; 
endforeach; wp_reset_postdata(); 
?> 
<div class="columns"> 
<?php 
foreach($cols as $key => $col) 
    echo '<div class="column column' . $key . '">' . $col . '</div>'; 
?> 
</div> 
+0

界定「不工作」。什麼都沒有出現? – pixeline 2012-01-16 20:44:40

+0

沒什麼出現。 – Tom 2012-01-17 00:16:20

+1

是其他模板標籤輸出?你是否獲得固定鏈接,標題等?一個愚蠢的問題 - 在文章文本編輯器或摘錄字段中是否有文本? – 2012-01-17 20:13:19

回答

1

對於環我始終堅持:

query_posts('cat=6&showposts=10'); 

while (have_posts()) { 
    the_post(); 

    // do stuff 
    the_excerpt(); 

} 
0

喚起後,您可以使用此代碼

<?php 
global $post; 
$args = array('numberposts' => 5, 'category' => 3); 


$myposts = get_posts($args); 
foreach($myposts as $post) : 
setup_postdata($post); ?> 

<?php the_title(); ?> 
<?php the_content(); ?> 

<?php endforeach; ?> 

更換要顯示後的貓和號碼。

並限制後字符使用此代碼

<a href="<?php the_permalink(); ?>"><?php substr($post->post_content, 0, XY); ?> ...</a> 

更改字符的(XY)要dispaly數...