2010-11-25 13 views
3

私はWordPressブログのカスタムテンプレートページに2つの記事を表示する必要がありますが、このコードは何も表示されません。the_content();私のWordPressのカスタムテンプレートページで何も印刷しません

$myposts = get_posts("numberposts=2&category=3"); 
foreach($myposts as $post) : the_content(); endforeach; 

が、私はprint_r($myposts);しようとした場合、私は私がこの問題を解決することができますarray..howがあることを言うことができますか? ありがとうございます

+0

を私はこれがどのように 'the_content()'作品ではないと思います。 'get_the_content()'を試してください(保証はありませんが、これらの関数は通常The Loopでしか利用できません) –

答えて

3

ヤフーはを使用する必要があります!

query_posts("numberposts=2&category=3"); 
while (have_posts()): the_post(); 
    the_content(); 
endwhile; 
0

あなたはこれを試すことができます: -

<ul> 
    <?php 
    global $post; 
    $myposts = get_posts('numberposts=5&offset=1&category=1'); 
    foreach($myposts as $post) : 
     setup_postdata($post); 
    ?> 
     <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> 
<?php the_content() ?> 
    <?php endforeach; ?> 
    </ul> 

かもしれ役に立つhttp://codex.wordpress.org/Template_Tags/get_posts 感謝。あなたが使用する前に

the_post(); 

6

は、この行を書く

the_content(); 
関連する問題