开发者

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

开发者 https://www.devze.com 2023-04-08 19:30 出处:网络
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?

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

精彩评论

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