how to show all untagged posts in wordpress

over on www.myconfinedspace.com I was having trouble keeping track of which posts had been properly tagged or not. using this code, you’ll be able to display the untagged posts. And edit button will appear when appropriate.

Please note this is a custom page template, so just create a blank text file, rename it “untagged.php” and upload it to your theme directory.  then just create a new page through wordpress and tell it to use the “untagged” template!

<?php
/*
Template Name: untagged
*/
?>

<br />
<hr />
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(‘showposts=500′.’&paged=’.$paged);
?>
<br />
<div style=”text-align:center;font-size:31px;”>
<?php posts_nav_link(‘ · ‘, ‘previous page’, ‘next page’); ?>
</div>
<br />
<center><?php if(function_exists(‘wp_pagenavi’)) { wp_pagenavi(); } ?></center>
<br />
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

<?php
$tag = get_the_tags();
if (!$tag) { ?>

<a href=”<?php the_permalink() ?>”><?php the_title(); ?>
</a> – – <?php edit_post_link(‘[Edit]’); ?><br />
<?php
}
endwhile;
endif; ?>

create

please note the large number of posts that will be shown. Since it’s only the post titles that are loading there shouldn’t be a problem with 500 of them at once, but your server may not be the uber powerhouse that mine is 😉 Another quirk of this bit of code is that each page is 500 posts of your material, and it only shows the ones that are untagged. so if you have untagged posts that are 4,000 posts back, you’ll need to click over to page 8 or 9 to see those posts pop up on this.

how to list your future posts in wordpress

Want to show what posts are coming up? add this bit of code in:

wordpress – how to show first attachment

add this to your theme’s “functions.php” page:


function list_first_image() {
$files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
if($files) :
$keys = array_reverse(array_keys($files));
$j=0;
$num = $keys[$j];
$image=wp_get_attachment_image($num, 'large', false);
$imagepieces = explode('"', $image);
$imagepath = $imagepieces[1];
$thumb=wp_get_attachment_thumb_url($num);
print " '$thumb' ";
endif;
}

alternatively you can also pass along some size requirements. this is the one that’s in use under each ‘single post’ on www.myconfinedspace.com :

function get_first_image() {
$files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
if($files) :
$keys = array_reverse(array_keys($files));
$j=0;
$num = $keys[$j];
$image=wp_get_attachment_image($num, 'large', false);
$imagepieces = explode('"', $image);
$imagepath = $imagepieces[1];
$thumb=wp_get_attachment_thumb_url($num);
print " wordpress   how to show first attachment";
endif;
}

once you have either of those added to your functions.php file, you can call them using :

or