[resolved] Filter Categories On Homepage (User Selectable)? (3 posts)

  1. freefally2k
    Posted 1 year ago #

    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?

  2. karpstrucking
    Posted 1 year ago #

    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:

      if ( is_home() && ( 'true' == $_GET['hide-category-11'] ) ) {
        query_posts( $query_string . '&cat=-11' );
  3. freefally2k
    Posted 1 year ago #

    Thanks so much for this karpstrucking, works like a charm :)

Topic Closed

This topic has been closed to new replies.

About this Topic