2012-01-16 10 views
0

the_excerpt関数を動作させることができません。ここでwordpress the_excerptが動作しません

私は

を使用していたコードは、私がループ権利を呼び出していないですか? the_excerptのために私のfunctions.phpにフィルターを使用していません。

任意の値を指定すると、任意の値を指定できます。あなたが表示したい猫のIDとポストの数を交換して、このコード

<?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; ?> 

を使用することができますポストを呼び出すための

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

while (have_posts()) { 
    the_post(); 

    // do stuff 
    the_excerpt(); 

} 
+0

は「動作しない」を定義します。何も現れませんか? – pixeline

+0

何も表示されません。 – Tom

+1

は他のテンプレートタグ出力ですか?あなたはパーマリンク、タイトルなどを取得していますか?愚かな質問 - 投稿テキストエディタまたは抜粋フィールドにテキストがありますか? –

答えて

1

そして、このコード

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

変更後の文字の使用を制限するためにあなたがdispalyしたい文字(XY)の数...

0

:私はいつもに固執Forループ

$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> 
関連する問題