First:
- Indent your code consistently, your code editor should do this automatically, if it doesn’t, you should change, I can recommend Sublime Text as a free option, but there are hundreds of others
- Don’t spam PHP tags,
<?php echo 'you'; ?><?php echo ' dont '; ?><?php echo 'need ';?><?php echo 'this'; ?>
, when<?php echo 'you can just open tags once and close them when your done?';?>
- Never use
query_posts
. If I was your employer I would have fired you for such a thing. Whoever taught you to use it, they did you a disservice. To fetch posts in WordPress, useWP_Query
orget_posts
, to modify a query, use thepre_get_posts
filter. Remember to callwp_reset_postdata
afterwards to clean up - Pick a style and stick to it, you either
if() {}
orif(): endif;
, don’t mix the 2 types, it just makes life difficult and your code difficult to read
As for your issue, just print out 9 posts. Wrap the 9th post in a div that’s hidden by default and toggle it’s visibility with javascript when you press a button.