
If you ever wanted to get a list of your blog posts that have no tags yet, here’s a nice recipe for you, where I’m going to show you how to easily create a custom loop and check out if your posts have tags or not.

If you ever wanted to get a list of your blog posts that have no tags yet, here’s a nice recipe for you, where I’m going to show you how to easily create a custom loop and check out if your posts have tags or not.
To get the list of un-tagged posts, simply paste this custom loop anywhere or your theme, or use a page template. This loop will only show posts that haven't been tagged yet.
<?php query_posts('orderby=title&order=asc&showposts=-1'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$tag = get_the_tags();
if (!$tag) { //Theses posts have no tags
the_title();
}
endwhile;
endif; ?>
That's all. Now, you can easily find which posts have no tags yet, and tag them!
4 Responses
I combined the above idea (list of untagged posts), with the Tags Archive idea (also recently detailed here on WP Recepies), and also with tag.php (the template for each individual tag’s page). It’s a total tag presentation solution.
Basically my tag archive shows a weighted list of the 50 most common tags, then a comprehensive alphabetical list of all the tags with a counter for the total # of tags (885 now). Then each Tag has it’s own page, with a big link at the top to “All 885 Tags” with the number dynamically counted. Fun stuff.
all this does is return a blank screen for me
is there perhaps more code that isn’t up there that I should be using?
here to answer my own question:
I have about 2,000 posts with no tags, so I changed the ‘-1′ to something a little more sane, like 20. unfortunately this loops only returns anything that’s true in that group of all the posts on the site. my first 20 posts had tags, so it was saying, ‘out of these first two posts, none have tags’.
This wasn’t the way I was expecting it to behave, which was to show the first 20 that were true for the condition of ‘no tag’.
I just upped the number to somewhere around 200, where my first untagged posts start to appear.
Trackbacks: