Support » Fixing WordPress » WP in protected directory, .htaccessa and failing permalinks

  • Resolved richarduk


    Okay, I’ve set up a password protected directory within my main site, and within that directory I’ve got WP in development for a client.

    The client can therefore access WP with the password and see what’s going on.

    I think the password protection has wiped the .htaccess. Every child category I go to shows exactly the same posts, even though the permalinks in the address bar change.

    Within WP, I can change the permalink ‘styles’ around (e.g. default, custom etc.) and WP accepts this quite happily, so it can’t be having any trouble in overwriting the .htaccess.

    The pastebin is here:

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    This is your problem.
    <?php query_posts('showposts=2'); ?>

    Using a query_posts changes the query to the parameters you give it. Only the parameters you give it. Since you didn’t specify to keep the existing parameters, you didn’t get to keep them. So going to, say, a category page doesn’t work because you are wiping out the category part of the main posts query right here.

    This is explained in the documentation in somewhat more detail, but the upshot is that in your case, you really wanted this line instead:
    <?php query_posts($query_string . 'showposts=2'); ?>


    It’s nearly there – if I remove <?php query_posts('showposts=2'); ?> then everything works fine, and I see all the posts, but if I use <?php query_posts($query_string . 'showposts=2'); ?> I get the ‘Sorry, no posts to show’ message.

    So I’m nearly there.

    I’ve come across this $query_string . before but never understood it – I’ll put more effort in this time.

    But thanks for getting me this far, I would never have guessed this!

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Ahh, my bad. Typo.

    That should have been:
    <?php query_posts($query_string . '&showposts=2'); ?>

    The ampersand is important.

    The $query_string is basically the automatically generated query parameters for query_posts. When you want to add to it instead of replace it, then you can add to it by adding more parameters onto the end of it.

    Spot on!

    I shall go and change my theme around.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP in protected directory, .htaccessa and failing permalinks’ is closed to new replies.