Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Page & Category Menu Bars (http://forum.bytesforall.com/forumdisplay.php?f=10)
-   -   Older / Newer links and excluding category (http://forum.bytesforall.com/showthread.php?t=12900)

vCopia Feb 20, 2011 07:30 AM

Older / Newer links and excluding category
 
I have the following code inserted Above The Loop in the ATO to exclude category #3 from appearing on the main pages of the web site (or search for 'em, etc.).

PHP Code:

<?php if (is_front_page() && !is_paged() )
$posts query_posts($query_string '&cat=-3'); ?>

Didn't think it through, though, because it does exactly what I asked it to... exclude cat 3 from the front page (only). When I click on the Older / Newer links, category 3 posts reappear. The idea was to create the illusion to visitors that category 3 posts weren't part of the main site, and were only accessible if you clicked the page tab I have set up for them.

After reading another posts herein I tried this code instead:

PHP Code:

<?php
if (is_home() and !(is_paged()) ) {
query_posts("cat=-3");
}
?>

Got the same result - worked on front page, but not older / newer pages. Makes sense.

Figured I either needed to:
  • change is_home or is_front_page to another command,
  • expand that section to include a command that referred to the Older / Newer links, or
  • add another segment of of code identical to the above and replace is_home or is_front_page with a tag that referred to whatever the Older / Newer links are IDed as.

Just know I ain't got it right. Please share any insights you have that'll bring my coding prowess up to speed with my goal so I can resume my spot at the clever table. Thanks.

juggledad Feb 20, 2011 11:25 AM

you need to test to see if you are paged and pass that to the query_post

vCopia Feb 20, 2011 12:02 PM

Got it! Thanks for the direction. Here's what I used and it seems to be working perfectly.

PHP Code:

<?php
if (is_home()) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=-3&paged=$paged");
}
?>

If you see an issue I haven't foreseen with this string, please let me know. Otherwise, I think my Seat has been restored. :) Thanks.

spam11@siknerd Nov 2, 2011 12:18 PM

If I'm understanding Wordpress and Atahualpa correctly, I'm having a similar problem. I have a category that I want only accessible if a user selects that tab from the menu. I don't want it to appear as a prev/next option when someone is reading a post. I inserted the above code on the top of my wp-content/themes/Atahualpa/index.php page: the unwanted category doesn't show up on the home page (good!); however, it does appear in prev/next on blog posts (bad!). Please advise: am I putting the code in the wrong spot? Or am I misreading what is written here and I need a different code? Thanks in advance!


All times are GMT -6. The time now is 08:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.