开发者

WP: shortcodes when using if(have_posts()) followed by while(have_posts())

I'm trying to minimize my code and have put together this little snippet, it doesn't seem to work howeve开发者_运维问答r. What am I missing?

query_posts( 'year=2011' );
if ( have_posts() );
while ( have_posts() );
echo 'test';
endwhile;
wp_reset_query();
endif;


I think that your problem is the question mark at the end of the if and at the end of while. IMy opinion is that you need a colon ":"

query_posts( 'year=2011' );
if(have_posts()):
    while(have_posts()):
        echo 'test';
    endwhile;
    wp_reset_query();
endif;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜