Posted on 4 August, 2008 By 8 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:

About

Kim Woodbridge is an accomplished Information and Technical Consultant specializing in the entire implementation of a WordPress based website including installation, theme design, upgrades, unique customizations and ongoing site maintenance.

Recent Comments

    • Victoria12: Wow! This are so cute. It is so much special when our kids do it on their own and give it us as a surprise gift.. So tou...
    • Catherine: I hope that the page owners have a plan for the transition. One concern is that Facebook doesn’t have a great method of ...
    • harm: You no longer can "Add to My Page" This used to be simple, using the facebook UI. Unfortunately facebook removed thi...
    • Phil Derksen: I was referencing plugin #1 in the list btw. :)...
    • Phil Derksen: Thanks for mentioning my Pin It button plugin. I'd love to hear what people think of it and what they'd like to see adde...

Wordpress Services

  • Installation, upgrades and maintenance
  • Conversion of existing html and css templates
  • Theme and plugin recommendations
  • CSS customizations
  • Troubleshooting and tweaks for unique situations
  • Customization for individual blogging goals and needs
  • Training and advice