Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Sidebars & Widgets (http://forum.bytesforall.com/forumdisplay.php?f=14)
-   -   Exclude category from Recent Posts in sidebar (http://forum.bytesforall.com/showthread.php?t=865)

paulae Mar 19, 2009 02:05 PM

Exclude category from Recent Posts in sidebar
 
I do not want the latest obituary posts showing up in the Recent Posts sidebar widget on the left.
http://larchmontgazette.com/wp27/

I want to be able to exclude obituaries and maybe some other categories, in the future, from the sidebar widget. I tried the Advanced Category Excluder plugin, but it didn't do a thing for me. I don't see any other likely plugins when I search the Wordpress plugin directory.

Help!

Flynn Mar 20, 2009 03:48 PM

Use one instance of the PHP code widget http://wordpress.org/extend/plugins/php-code-widget/ and inside the widget put:
PHP Code:

<ul>
<?php
    $recentPosts 
= new WP_Query();
    
$recentPosts->query('showposts=5&cat=-XX,-YY,-ZZ');
?>
<?php 
while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>

In showposts=5&cat=-XX,-YY,-ZZ replace 5 with amount of posts and XX, YY and ZZ with the ID's of the categories that should be excluded

paulae Mar 20, 2009 04:24 PM

I got it working, thanks!

Very nice.

You're the best!

Flynn Apr 21, 2009 06:18 PM

That's kinda funny, I just googled for this and found my own post :p

paulae Apr 21, 2009 07:23 PM

Mirrors within mirrors.

anou Jan 29, 2011 02:29 AM

Just what i was searching for.
Thank you

Helleshoj Mar 18, 2011 05:04 AM

Interesting, but for one or another reason in my site it still shows all the categories. Wordpress 3.1, PHP 5.

juggledad Mar 18, 2011 05:13 AM

What version of Atahualpa?
What is the URL?

dkat1043 Apr 13, 2011 10:33 AM

Sorry to jump in, but I have a similar problem. I want to exclude a category from the next/previous listing on the single-post page. I've used a plug-in to disable the category from appearing on the home page, but it shows up in the sidebar listing of categories on the single-post page, and in the next/previous header. I'm not sure where in Atahualpa to look to edit this page template, or whether there's an easy way to keep the category out of these listings. Using theme v. 3.2, Wp v 3.1.1. Thanks.

juggledad Apr 13, 2011 11:14 AM

Version 3.2?? Wow are you using an old version of Atahualpa.

The things in the sidebar are widgets. Without the site URL or knowing what widget you are using I can't tell you if it is an Atahualpa widget or from someone else. If it is from someone else then you have to look at the plugin code and/or contact the plug-in's author about this.

dkat1043 Apr 13, 2011 11:28 AM

Yes, it is an older version. It took a while to get the site set up and customized, and I've been concerned that upgrading might break something, but I guess I have to take the plunge at some point.

An example of the single post page is here: http://tiffanyannlewis.com/blog2/?p=4678 You can see that the next post in the header is a date, which is the title of a post in the category called Itinerary. Itinerary shows up in the category list on the right, but if you go to the home blog page, it does not, as I intended it. I'm using a plugin called Category Exclusion.

So I'm wondering where in the code I can go to get Itinerary Category to not show up in the category list on the single post page, and not appear in the Next Post listing as well. I'm using the theme's default Category widget, modified by a plugin called Category Order.

Thanks for your help, and please let me know if you need more info.

juggledad Apr 13, 2011 02:25 PM

So you are using the 'Categories' widget in the right sidebar...correct?

This widget is part of WordPress and not Atahualpa. What you should do is a google search on 'wordpress category plugin' and see if there is one that will let you exclude a category.

paulae Apr 13, 2011 02:34 PM

I use a combination of Enhanced Recent Posts and Widget Logic plugins to control placement of categories.

dkat1043 Apr 13, 2011 07:21 PM

Thanks to both of you for your help. I'll check the code and the plugins.

Dan

shawx Mar 22, 2013 04:55 AM

Hello all

I want to customize my wordpress widget by excluding first 3 posts from recent posts. I do not want to show them. I've set recent posts to show to 10 currently.

Please help. thanks

juggledad Mar 22, 2013 05:40 AM

what version of Atahualpa and Wordpress are you on?
What widget are you talking about?

belantos Apr 9, 2013 02:45 AM

Quote:

Originally Posted by Flynn (Post 5373)
That's kinda funny, I just googled for this and found my own post :p

LOL. Google replaces our memory :)

canhtt Apr 9, 2013 08:34 AM

Quote:

Originally Posted by Flynn (Post 3334)
Use one instance of the PHP code widget http://wordpress.org/extend/plugins/php-code-widget/ and inside the widget put:
PHP Code:

<ul>
<?php
    $recentPosts 
= new WP_Query();
    
$recentPosts->query('showposts=5&cat=-XX,-YY,-ZZ');
?>
<?php 
while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>

In showposts=5&cat=-XX,-YY,-ZZ replace 5 with amount of posts and XX, YY and ZZ with the ID's of the categories that should be excluded

oh, so good, tks verry much


All times are GMT -6. The time now is 03:36 AM.

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