Posted on 4 August, 2008 By Kim Woodbridge 5 Comments

Exclude WordPress Categories for Hidden Twitter Tools Digest Posts

Last week I wrote an overview of the Wordpress plugin, Twitter Tools. In the article, I discussed the option in Twitter Tools to send all of the your daily tweets to Wordpress as a digest post. While I like the idea of using WordPress to archive twitter, I don’t want a daily post of my tweets listed on the front page or in the archives as I consider it to be content padding and really boring for most readers. Since you can assign a category to the daily post digest, I researched the wordpress code needed to exclude categories from the front page and from archives and then spent part of this morning testing and implementing it on this site.

This ended up being more complicated than I anticipated. The template used on this site references the categories in numerous locations and I had to add code and make changes to this template in the following locations; front page, archives page, category list in sidebar, list of recent posts in sidebar, and list of recent posts in the footer. Below I will outline the steps and the code needed to send your daily twitter postings to your Wordpress blog but to not have them displayed.

  1. Create a new Wordpress category that will only be used for the digest posts. I named mine ‘digest’. Note the number of the category as you will need it in the exclude code.
  2. Go to Settings > Twitter Tools and set that category and the user. I am the only user of this blog so I didn’t have to change that setting.
  3. Set Create a daily digest blog post from your tweets? to Yes. I temporarily changed Create a tweet when you post in your blog? to No because I didn’t know if the digest post would be sent to Twitter even if it was excluded. I still need to test this.
  4. Please note that I can still not display code in a post without that code being executed even when I place it between the code tags. So all code snippets need “< ?" and the beginning and "? >” at the end. Sorry about that and if anyone has any ideas about this, I would appreciate a solution. On the main index page add

    if (in_category(’23′)) continue;

    after

    if (have_posts()) :
    while (have_posts()) : the_post();

    This will exclude the digest post from the front page of your site. Make sure to change ‘23′ to the number of your category.

  5. Add the same piece of code to your archives page, if you don’t want the twitter digest displayed on that page. I contemplated leaving it available in the archives but decided to be consistent and remove all instances of the digest and to only have it available to me as a backup. If you have other archive type pages, such as categories, you will want to add the code there as well.
  6. I then needed to find a way to exclude the digest post from the two instances of Recent Posts. I use a Wordpress query to pull recent posts to the sidebar. If you are using a plugin and displaying Recent Posts as a sidebar widget, I am not sure how to implement the exclusion.

    php $recent = new WP_Query(”showposts=8&cat=-23″); while($recent->have_posts()) : $recent->the_post();

    I added &cat=-23 to remove the category of the digest posts from the list of recent posts. Again, I needed to do this in the sidebar and the footer. Make sure to use the minus sign in from of the category number.

  7. Finally, I need to edit the Category List in the sidebar so that the Digest category was not displayed. This made me remember why I don’t like using widgets, even when it is easier to do so. My list of categories was displayed via a widget but since I couldn’t edit the code for that, I entered the category code manually.
      wp_list_categories(’exclude=23&title_li=’);

    Again, the excludes the category from the list via the category number. &title_li= is used to supress the category heading. This is not necessary for category exclusion but was something I needed to do to maintain consistent styling.

This is what a daily twitter digest post would like if you weren’t hiding it. Of course, it would have your own blog style.

There are a couple of things that I’m not sure of and still need to test.

  1. Will the digest post show up in my RSS feed even though it has been excluded from being displayed?
  2. If I turn on the posting to twitter with each new post option in Twitter Tools, will a notification be sent to Twitter when there is a new digest post?
  3. What time of day will the digest post arrive? The one that I took the screenshot of arrived almost immediately after I turned on the feature and was a digest of my twitter activity from yesterday.

I am going to continue testing this. I would like a twitter archive, even though my archive will only start from yesterday and won’t contain 900+ tweets. But there does seem like a lot of parts to this that need to work correctly and I’m not sure if it is something that is worth maintaining. I did, however, learn how to exclude categories in Wordpress pages and that must surely have many practical uses.

Resources:

Recent Comments

    • Fábio N Sarmento: Do you have any idea how can i exclude a certain category, when the TT do the "new blog post" update, i want it show al...
    • Kikolani: Those are some good, patriotic themes that could be modified to work year round. Thanks for the round up! ~ Kristi...
    • Jannie Funster: Kim, that is just the sweetest shout-out ever. I guess no good deed with you goes unappreciaated, and in such a public ...
    • Kim Woodbridge: Hi - Is this for a fan page or a profile page? On a fan page go to Edit Page. In the list of Applications click on the ...
    • Kim Woodbridge: Hi Valerie - Sometimes when I'm really tired I just sit here and mindlessly click around the internet and the same thing...
    • Kim Woodbridge: Hi Patricia, Thank you so much for the kind words - I really appreciate it and you comment has made my day :-) Hav...
    • Kim Woodbridge: Hi John - Jeff is wonderful and a really nice person. They already have some great stuff on the new site and I can't wa...
    • Kim Woodbridge: Hi Siel - It's mostly fun - but people are difficult sometimes just like in a real job. I'm much more relaxed, which is...