What’s a better alternative to this code?

Thanks to those who’ve suggested fixes.

I couldn’t get my normal pagination working with either, but did find an alternate solution which seems to work and which I’ll include here as possible help to others (because I’ve seen various requests for similar).

<?php
$wp_query = new WP_Query();
$wp_query->query('post_type=host&sort_by=title&order=ASC&showposts=1&paged='.$paged    );
get_template_part( 'page-templates/partial/paginate' );

while ($wp_query->have_posts()) : $wp_query->the_post();
echo "<p>";
the_title();
echo "</p>";
endwhile;

get_template_part( 'page-templates/partial/paginate' );
wp_reset_postdata();
?>

The contents of the included partial page template are:

<?php
// Inserts block of numbered links to other posts, on posts/post summaries and search pages.

if (function_exists("pagination")) {pagination($additional_loop->max_num_pages);}

?>

And the function is:

function pagination($pages="", $range = 3)
{
$showitems = ($range * 2)+1;

global $paged;
if(empty($paged)) $paged = 1;

if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}

if(1 != $pages)
{
echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo " <a href="".get_pagenum_link(1)."">&laquo; First</a> ";
if($paged > 1 && $showitems < $pages) echo " <a href="".get_pagenum_link($paged - 1)."">&lsaquo; Previous</a> ";

for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&(!($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems))
{
 echo ($paged == $i)? "<span class=\"current\"> ".$i." </span>":"<a href="".get_pagenum_link($i)."" class=\"inactive\"> ".$i." </a>";
}
}

if ($paged < $pages && $showitems < $pages) echo " <a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a> ";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems <     $pages) echo " <a href="".get_pagenum_link($pages)."">Last &raquo;</a> ";
echo "</div><!-- /pagination -->\n";
}
}

I don’t claim credit, nor pretend to understand enough about how/why this works. And I’m puzzled that in the query, if ‘$wp_query’ is renamed (to something like ‘the_query’) the pagination vanishes.

tech