2013-10-14 62 views
0

我創建了一個自定義主題,然後是一個自定義類型,並且當我嘗試將一個(更多)鏈接添加到該帖子時,該錨點不起作用。這是我的代碼:錨點不在wordpress工作,

<main id="main" class="site-main" role="main"> 

      <?php $temp_query = $wp_query; 
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
      $args=array(
       'caller_get_posts'=>1, 
       'post_type' => 'enfant', 
       'paged'=>$paged 
      ); 
      $wp_query = new WP_Query($args); 

     ?> 

     <?php while ($wp_query->have_posts()) : $wp_query->the_post(); 
      $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID)); 
     ?> 

      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
       <header class="top-cont"> 
        <h1 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1> 
       </header><!-- .entry-header --> 

       <div class="entry-content"> 
    <!-- first one -->    <a href="<?php the_permalink();?>"><img src="<?php echo $src[0];?>" /></a> 

        <?php 
         $terms = get_the_terms($post->ID, 'maladies', '', ', ',''); 
         if (!empty($terms)){ 
          $numTerm = 0; 
          echo "<h3>Maladie : </h3>"; 
          echo "<p>"; 
          foreach($terms as $term) { 
           $numTerm++; 
           if ($numTerm == 1){ 
            echo " ".$term->name; 
           } 
           else{ 
            echo ", ".$term->name; 
           } 
          } 
          echo "</p><br/>"; 
         } 
        ?> 
     <!-- second one -->   <a href="<?php the_permalink() ?>" >Lire plus ...</a> 
        <p><?php the_excerpt(); ?></p> 

        <?php 
         wp_link_pages(array(
          'before' => '<div class="page-links">' . __('Pages:', 'adelia'), 
          'after' => '</div>', 
         )); 
        ?> 

       </div><!-- .entry-content --> 
       <div class="foot"></div> 
       <!--<?php edit_post_link(__('Edit', 'adelia'), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>'); ?>--> 
      </article><!-- #post-## --> 


      <?php 
       // If comments are open or we have at least one comment, load up the comment template 
       /*if (comments_open() || '0' != get_comments_number()) 
        comments_template();*/ 
      ?> 

     <?php endwhile; // end of the loop. ?> 

這兩條線都不起作用。

+2

很難確定沒有鏈接來查看實際的代碼(live或dev網站),但很可能你有一些JS衝突/錯誤。檢查你的控制檯和報告.. –

+0

我已經檢查,但沒有找到關於鏈接或類似的東西。 – krachleur

+0

錯誤不會是「鏈接」特定的。但最有可能與jQUery或JS相關。如果js錯誤發生在鏈接本身之前,它可以打破(停止)之後出現的所有腳本.. –

回答

0

它很難找出bug: 我已經爲你嘗試了一些東西,希望它能起作用。

 <main id="main" class="site-main" role="main"> 

     <?php $temp_query = $wp_query; 
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
     $args=array(
      'caller_get_posts'=>1, 
      'post_type' => 'enfant', 
      'paged'=>$paged 
     ); 
     $wp_query = new WP_Query($args); 

    ?> 

    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); 
     //$src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID)); 
    ?> 

     <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
      <header class="top-cont"> 
       <h1 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1> 
      </header><!-- .entry-header --> 

      <div class="entry-content"> 
<!-- first one -->    <a href="<?php the_permalink();?>"><img src="<?php echo wp_get_attachment_image_src(get_post_thumbnail_id($post->ID));?>" /></a> 

       <?php 
        $terms = get_the_terms($post->ID, 'maladies', '', ', ',''); 
        if (!empty($terms)){ 
         $numTerm = 0; 
         echo "<h3>Maladie : </h3>"; 
         echo "<p>"; 
         foreach($terms as $term) { 
          $numTerm++; 
          if ($numTerm == 1){ 
           echo " ".$term->name; 
          } 
          else{ 
           echo ", ".$term->name; 
          } 
         } 
         echo "</p><br/>"; 
        } 
       ?> 
    <!-- second one -->   <a href="<?php the_permalink() ?>" >Lire plus ...</a> 
       <p><?php the_excerpt(); ?></p> 

       <?php 
        wp_link_pages(array(
         'before' => '<div class="page-links">' . __('Pages:', 'adelia'), 
         'after' => '</div>', 
        )); 
       ?> 

      </div><!-- .entry-content --> 
      <div class="foot"></div> 
      <!--<?php edit_post_link(__('Edit', 'adelia'), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>'); ?>--> 
     </article><!-- #post-## --> 


     <?php 
      // If comments are open or we have at least one comment, load up the comment template 
      /*if (comments_open() || '0' != get_comments_number()) 
       comments_template();*/ 
     ?> 

    <?php endwhile; // end of the loop. ?> 

謝謝。

+0

非常感謝幫助,對於第一個命題,我檢查了控制檯錯誤,但我發現像盒子大小等其他錯誤,但沒有找到關於我們的情況的東西,第二個答案,我做了修改,但是,圖像不顯示。 TNX很多,我等待更多的答案(如果可能的話)! – krachleur