GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Wordpress Gurus... Help Me Please... Exclude Category Posts! (https://gfy.com/showthread.php?t=947486)

Dennis69 01-08-2010 05:34 PM

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 :mad:

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 :thumbsup

fris 01-08-2010 05:48 PM

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”);
} ?>


Dennis69 01-08-2010 10:15 PM

Thanks fris... you rock :thumbsup

Spankys Teens 01-08-2010 10:44 PM

there's also a plugin that does it all.
Look for "Simply Exclude"

Dennis69 01-08-2010 10:49 PM

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

harvey 01-09-2010 01:04 AM

Quote:

Originally Posted by Dennis69 (Post 16730733)
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;
?>


harvey 01-09-2010 01:06 AM

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

Spankys Teens 01-09-2010 05:55 AM

jeeez, did u just miss that there's a ready made plugin - talk about stubborn :)

fris 01-09-2010 06:23 AM

Quote:

Originally Posted by Spankys Teens (Post 16731267)
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.

Dennis69 01-09-2010 08:26 AM

Quote:

Originally Posted by harvey (Post 16730993)
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 :thumbsup

Dennis69 01-09-2010 08:28 AM

Quote:

Originally Posted by Spankys Teens (Post 16731267)
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!

Spankys Teens 01-09-2010 11:22 PM

sowwy - my bad :)


All times are GMT -7. The time now is 12:37 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123