2012-02-29 154 views
1

好吧,我將盡力解釋這個最好的我可以,所以請裸露在我身邊。將Wordpress的index.php鏈接到single.php

我目前正在研究一個網站,我最初是從頭編碼,但現在整合了wordpress,因爲我的客戶想要一個後端。

這是我的問題,我使用index.php爲主要博客文章(到目前爲止工作正常)。但是我想要做的只是對這些帖子的摘錄(一個簡短的摘要),然後我希望用戶能夠點擊「閱讀更多」鏈接以獲取該特定文章/帖子的完整頁面(我認爲這將是single.php(如果我沒有弄錯)

所以,我們去了,這裏是我的主要博客頁面的代碼(即index.php - 我只包括PHP代碼與自己相關這裏不是整個頁面):

      <div id="content">    
         <table cellpadding="0" cellspacing="0" border="0"> 
         <tr> 
         <td style="vertical-align: text-top; padding-right: 20px;"><h1>Blog</h1></td> 
         <td style="vertical-align: text-top; padding-left: 20px;"> 
         <h1>Archives</h1> 
         <select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"> 
         <option value=""><?php echo esc_attr(__('Select Month')); ?></option> 
         <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> 
         </select> 
         </td> 
         <tr> 
         <td style="padding-right: 20px;">     
         <?php 
         $temp = $wp_query; 
         $wp_query= null; 
         $wp_query = new WP_Query(); 
         $wp_query->query('posts_per_page=5' . '&paged=' . $paged); 
         while ($wp_query->have_posts()) : $wp_query->the_post(); 
         ?> 
         <div style="background-color: #fff; margin-top: 0px; padding: 20px 20px 20px 20px; border-color: #819cc7; border-style: solid; border-width: thin;"> 
         <h2><a href="<?php $permalink = get_permalink($id); ?>"><?php the_title(); ?></a></h2> 
         <p><?php the_post_thumbnail(); ?></p> 
         <p><?php the_content($more_link_text , '' , $more_file); ?></p> 
         <p><?php _e('Filed under&#58;'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><p> 
         <p><?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> <?php edit_post_link('Edit', ' &#124; ', ''); ?> 
         <p>Date posted: <?php the_date(); ?></p> 
         <!--Don't know if I need the two lines below 
         <p><?php //get_post_permalink(); ?></p> 
         --> 
         </div> 
         <p><?php endwhile; ?></p> 
         <?php $wp_query = null; $wp_query = $temp; ?> 
         </td> 
         <td style="padding-left: 20px;">&nbsp;</td> 
         </tr> 
         </table> 
         </div> 

這是我有我的single.php頁面代碼:

<?php get_header(); ?> 
    <section> 
     <article id="white_bg"> 
      <div class="content_border"> 
       <div id="content"> 
       <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> 
       <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
       <p><?php the_post_thumbnail(); ?></p> 
       <p><?php the_content(); ?></p> 
       <p><?php _e('Filed under&#58;'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?></p> 
       <p><?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> <?php edit_post_link('Edit', ' &#124; ', ''); ?></p> 
       <br /> 
       <?php comments_template(); ?> 
       <?php endwhile; ?> 
       <div> 
       <?php previous_post_link('< %link') ?> <?php next_post_link(' %link >') ?> 
       </div> 
       <?php endif; ?> 
      </div> 
      </div> 
     </article><!--end main article--> 
    </section><!--end main content section--> 
<?php get_footer(); ?>  

我一直試圖破譯這幾天,如果不是幾周,所以任何幫助,非常感謝。

我只是希望人們能夠看到的總結文章/後,點擊閱讀將採取更多鏈接的single.php在那裏他們可以查看完整的文章/後和評論,如果他們喜歡。

謝謝你閱讀/幫助,如果你可以!

+0

喜丹尼爾,首先...感謝你在百忙之中閱讀我的問題和回答的時間。 我實際上曾嘗試使用'the_excerpt',它工作正常。但我的問題是,當人們點擊的編碼使用「the_excerpt」「​​閱讀更多」鏈接,該鏈接不會將用戶帶到其它頁面這將顯示整個文章。相反,如果您將鼠標懸停在「閱讀更多」鏈接上,它將鏈接到您已在的同一頁面。對不起,我的問題不是很清楚。任何額外的幫助將不勝感激。謝謝! – KRS77 2012-03-03 00:25:53

回答

相關問題