2013-01-04 42 views
1

我在主頁上的博客模板中使用摘錄來顯示2頁摘錄,閱讀更多按鈕和1個帶有閱讀更多按鈕的最新博客帖子。wordpress post post excerpts issue

下面是使用

<?php 
/*******PAGES SECTION CUSTOM*******/ 
    $args=array(
    'orderby' =>'parent', 
    'order' =>'asc', 
    'post_type' =>'page', 
    'post__in' => array(34,36), 

    ); 
    $page_query = new WP_Query($args); ?> 
<div class="pagesarea left"> 
<?php while ($page_query->have_posts()) : $page_query->the_post(); ?> 
    <div class="section"> 
    <h2 class="homeh2"><a href="<?php the_permalink();?>"><?php the_title();?></a></h2> 
<?php the_excerpt(); ?> 
     <p class="readmore"><a href="<?php the_permalink();?>">Read More</a></p> 
</div> 
<?php endwhile; ?> 




<?php 
           /*******LATEST NEWS SECTION*******/ 

      $news_text = get_theme_option(tk_theme_name.'_home_news_text'); 
      $news_per_page = get_theme_option(tk_theme_name.'_home_news_number'); 
      $blog_id = get_option('id_blog_page'); 
      $blog_url = get_permalink($blog_id); 

       if($hide_news == 'yes') {}else{ 
     ?> 

        <div class="section last"> 
<h2 class="homeh2"><a href="<?php the_permalink();?>"><?php _e('Latest News ', tk_theme_name) ?></a></h2> 




       <?php 
       $post_counter = 1; 
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 0; 
       $args=array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $news_per_page, 'ignore_sticky_posts'=> 1); 

       //The Query 
       query_posts($args); 

       //The Loop 
       if (have_posts()) : while (have_posts()) : the_post(); 
       $post_day = get_the_time('d M'); 
       $post_year = get_the_time('Y'); 
       $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'home-news'); 
       $post_cats = get_the_category_list(',', $post->ID); 
       $cat_array = explode(',', $post_cats); 
       $number_of_cats = count($cat_array); 
       $cat_counter = 1; 
       $format = get_post_format(); 
       ?> 


         <p class="title"><?php echo $post_day?> 
         <?php echo $post_year?> 

         <?php the_title()?> 
         </p> 

           <?php the_excerpt(); ?> 
<p class="readmore"><a href="<?php the_permalink();?>">Read More</a></p> 
         </div> 

      <?php $post_counter++;endwhile; ?> 
      <?php else: ?> 
      <?php endif; ?> 


     <?php } // if news ?> 

代碼工作了2頁的代碼,但該職位不採取摘錄它採用了全文,並溢出p標籤。

的鏈接網址爲:http://green.romeomothersugar.co.uk

任何幫助,將不勝感激!

回答

1

當我檢查它時,它似乎將您的句子作爲一個單詞。雖然我認爲如果插入一些真實/正確的數據,它會得到解決。

包裝詞的快速解決方案是嘗試給CSS以下p tag

word-wrap: break-word;

+0

謝謝!永遠不會找到這個! –

+0

快樂來幫助你:)快樂編碼! – Rikesh

1

看來你的問題有什麼與你的代碼,並做以數據庫後的實際內容。

檢查源代碼後,所有單詞'test'後面跟着一個&nbsp;,即非破壞空格字符。這種說法就是這樣,它是一個HTML實體,旨在防止任何換行符,例如當您格式化表格數據並希望在一行上輸入名字和姓氏時。

嘗試進入你的WordPress的管理區域並編輯違規的帖子。將所見即所得狀態更改爲HTML編輯模式,並查看它是否與Test test test test testTest&nbsp;test&nbsp;test&nbsp;一致。如果是後者,Wordpress會將整篇文章解讀爲一個單詞,所以Wordpress沒有理由不將所有內容都包含在摘錄中,其中有一個默認的55個字限制。

此外,您的文本溢出的原因與&nbsp;實體有關。同樣,該行不會像通常那樣中斷,因此該行文本溢出了div.section list