Posted on 4 August, 2008 By Kim Woodbridge 8 Comments

Exclude WordPress Categories for Hidden Twitter Tools Digest Posts

 
Share

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

    • Ari Herzog: Agreed on the updates/inbox snafu. I rarely see page updates and I know where they are! .-= Ari Herzog´s last blog .....
    • jayson: Kim, Love the themes. I am looking to update the theme on my site to something more appropriate. My site is all abou...
    • vered: "I wish more people would use this. I think it’s silly when I get updates for things occuring in Kansas and California –...
    • Dennis Edell @ Direct Sales Marketing: I was speaking generally, not specifically this month. how exactly do you work things? .-= Dennis Edell @ Direct Sales M...
    • Lucy Beer: Unfortunately I think next to no-one actually sees those "Updates". They're buried in a subsection of the inbox and I do...
    • Kim Woodbridge: Hi Marbella - Thanks! I had a great time....
    • Kim Woodbridge: Hi Julie - I'll probably try kayaking again next summer but I don't know if I will become much of a kayaker - I had a di...
    • Kim Woodbridge: Hi Vered - If you ever get the chance, you should go. It's like a different world - it's so quiet and peaceful....

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.

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