wordpress模板中的多个循环打破永久链接

I have been working with a template bought from one of the wordpress theme marketplaces and I've added a second loop to this particular template file to pull in the content from the "page", after custom post type "portfolio" posts are displayed.

The portfolio post types display an image, linked title, excerpt and "read more" link. The links are rendering in the code but cannot be clicked on, and I cannot work out why this is happening. Any insight would be greatly appreciated.

Here's the code for the page:

<?php
/**
 * Template Name: Page No Top Text
 */

get_header(); ?>
<!-- #content -->
<div class="container_12 primary_content_wrap clearfix">
  <div id="content" class="grid_12">
      <?php include_once (TEMPLATEPATH . '/title.php');?>
   <?php global $more;  $more = 0;?>
   <?php $values = get_post_custom_values("category-include"); $cat=$values[0];  ?>
   <?php $catinclude = 'portfolio_category='. $cat ;?>

   <?php $temp = $wp_query;
   $wp_query= null;
   $wp_query = new WP_Query(); ?>
   <?php $wp_query->query("post_type=portfolio&". $catinclude ."&paged=".$paged.'&showposts=99'.'&orderby=date&order=asc'); ?>
   <?php if ( ! have_posts() ) : ?>
   <div id="post-0" class="post error404 not-found">
    <h1 class="entry-title"><?php _e( 'Not Found', 'theme1577' ); ?></h1>
    <div class="entry-content">
     <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'theme1577' ); ?></p>
     <?php get_search_form(); ?>
   </div><!-- .entry-content -->
 </div><!-- #post-0 -->
<?php endif; ?>
<div id="gallery" class="one_column">
  <ul class="portfolio">
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <?php
    $custom = get_post_custom($post->ID);
    $lightbox = $custom["lightbox-url"][0];
    ?>

    <li>
      <div class="clearfix">
       <?php if($lightbox!=""){ ?>
       <a class="image-wrap" href="<?php echo $lightbox;?>" data-gal="prettyPhoto[gallery]" title="<?php the_title();?>"><?php the_post_thumbnail( 'portfolio-post-thumbnail-xl' ); ?><span class="zoom-icon"></span></a>
       <?php }else{ ?>
       <a class="image-wrap" href="<?php the_permalink() ?>" title="<?php _e('Permanent Link to', 'theme1577');?> <?php the_title_attribute(); ?>" ><?php the_post_thumbnail( 'portfolio-post-thumbnail-xl' ); ?></a>
       <?php } ?>
       <div class="folio-desc">
        <h3><a href="<?php the_permalink(); ?>"><?php echo the_title('','',FALSE);?></a></h3>
        <p class="excerpt">
              <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,55);
              //the_content();?>
            </p>
            <a href="<?php the_permalink() ?>" class="button"><?php _e('Read more', 'theme1577'); ?></a>
          </div>
        </div>
      </li>

    <?php endwhile; ?>

  </ul>

  <br>

  <div class="clear"></div>
</div>

<?php if(function_exists('wp_pagenavi')) : ?>
    <?php wp_pagenavi(); ?>
<?php else : ?>
  <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  <nav class="oldernewer">
    <div class="older">
      <?php next_posts_link( __('&laquo; Older Entries', 'theme1577')) ?>
    </div><!--.older-->
    <div class="newer">
      <?php previous_posts_link(__('Newer Entries &raquo;', 'theme1577')) ?>
    </div><!--.newer-->
  </nav><!--.oldernewer-->
<?php endif; ?>
<?php endif; ?>
<!-- Page navigation -->

<?php $wp_query = null; wp_reset_query(); wp_reset_postdata(); $wp_query = $temp;  ?>
</div>
<!-- #content -->
<div class="container_12 fullWidthContent clearfix">
  <div class="grid_12">
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); the_content(); endwhile;  ?>
  </div>
</div>
<!-- end #main -->
</div>
<?php get_footer(); ?>