Support » Fixing WordPress » Filter Categories On Homepage (User Selectable)?

  • Resolved freefally2k

    (@freefally2k)


    Hi,
    At the moment I am excluding a category using the following code:
    <? php if ( is_home() ) {query_posts($query_string . '&cat=-11'); } ?>

    I want to make it default so the content shows (removing that code) but then the user has an option to hide it, e.g. have a “Don’t show content from category 11 link.

    I have tried something along the lines of having index.php and index2.php and having the above code in the index2, however I get the “Not Found” message.

    How could I do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You could add a link to the page that includes a URL parameter, like index.php?hide-category-11=true and then check for that parameter in the file:

    <?php
      if ( is_home() && ( 'true' == $_GET['hide-category-11'] ) ) {
        query_posts( $query_string . '&cat=-11' );
      }
    ?>

    Thanks so much for this karpstrucking, works like a charm 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter Categories On Homepage (User Selectable)?’ is closed to new replies.