Wordpress Gurus... Help Me Please... Exclude Category Posts!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis69
    Confirmed User
    • Feb 2003
    • 1685

    #1

    Wordpress Gurus... Help Me Please... Exclude Category Posts!

    I'm trying to exclude a category from displaying it's post on the pages of my blog... I can get it work but when I do you can't navagate to other older posts

    Here is the code I'm taking from wordpress help...

    Code:
    <?php
       if (is_home()) {
          query_posts("cat=-3");
       }
    ?>
    And I'm adding it before the loop

    Code:
    				<div id="content">
                                                       (INSERTING ABOVE CODE ON THIS LINE)	
    					<?php if (have_posts()) : ?>	
    						<?php while (have_posts()) : the_post(); ?>
    What am I doing wrong

    Thanks in advance for the help
    HaHaHa
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #2
    you have to handle pagination

    Code:
    <?php if (is_home()) {
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts(“cat=-3&paged=$paged”);
    } ?>
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

    Comment

    • Dennis69
      Confirmed User
      • Feb 2003
      • 1685

      #3
      Thanks fris... you rock
      HaHaHa

      Comment

      • Spankys Teens
        Confirmed User
        • May 2005
        • 1414

        #4
        there's also a plugin that does it all.
        Look for "Simply Exclude"
        Banners - Design - TGP & more
        Trade: Teenies In Action
        icq: 256664696

        Comment

        • Dennis69
          Confirmed User
          • Feb 2003
          • 1685

          #5
          Just tryed that code Fris and I get
          Parse error: syntax error, unexpected '='
          Any idea what the problem could be?
          HaHaHa

          Comment

          • harvey
            Confirmed User
            • Jul 2001
            • 9266

            #6
            Originally posted by Dennis69
            Just tryed that code Fris and I get
            Parse error: syntax error, unexpected '='
            Any idea what the problem could be?
            are you closing the call properly? The code fris posted is correct and should work, it's the common solution used for your problem as developed by Kafkaesqui, one of WP main developers.

            Anyway, alternatively you may try this with the is_home approach to see if it works (change is_archive to true if needed):

            Code:
            <?php
            $limit = 10;
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            query_posts('cat=-3&paged=$paged' . '&posts_per_page=10' .'showposts=' . $limit . '&paged=' . $paged);
            $wp_query->is_archive = false; $wp_query->is_home = true;
            ?>
            This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth

            Comment

            • harvey
              Confirmed User
              • Jul 2001
              • 9266

              #7
              aaah, now that I take a closer look to the code fris posted I see the problem. Instead of copy/pasting the code as fris posted, do it like this:

              Code:
              <?php if (is_home()) {
              $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
              query_posts("cat=-3&paged=$paged");
              } ?>
              just a formatting problem
              This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth

              Comment

              • Spankys Teens
                Confirmed User
                • May 2005
                • 1414

                #8
                jeeez, did u just miss that there's a ready made plugin - talk about stubborn
                Banners - Design - TGP & more
                Trade: Teenies In Action
                icq: 256664696

                Comment

                • fris
                  Too lazy to set a custom title
                  • Aug 2002
                  • 55679

                  #9
                  Originally posted by Spankys Teens
                  jeeez, did u just miss that there's a ready made plugin - talk about stubborn
                  some people like to get away without using as many plugins as possible, but advanced category excluder is a good one.
                  Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                  Comment

                  • Dennis69
                    Confirmed User
                    • Feb 2003
                    • 1685

                    #10
                    Originally posted by harvey
                    aaah, now that I take a closer look to the code fris posted I see the problem. Instead of copy/pasting the code as fris posted, do it like this:

                    Code:
                    <?php if (is_home()) {
                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                    query_posts("cat=-3&paged=$paged");
                    } ?>
                    just a formatting problem
                    Thanks Harvey and Fris... everything is working fine now
                    HaHaHa

                    Comment

                    • Dennis69
                      Confirmed User
                      • Feb 2003
                      • 1685

                      #11
                      Originally posted by Spankys Teens
                      jeeez, did u just miss that there's a ready made plugin - talk about stubborn

                      I didn't miss it but I'd rather use plugins for the big stuff rather then bloat my blog with a bunch of plugins... especially when it only a few words of code and some help to get it working right!
                      HaHaHa

                      Comment

                      • Spankys Teens
                        Confirmed User
                        • May 2005
                        • 1414

                        #12
                        sowwy - my bad
                        Banners - Design - TGP & more
                        Trade: Teenies In Action
                        icq: 256664696

                        Comment

                        Working...