2013-01-04 2 views
1

홈 페이지의 블로그 템플릿에서 발췌문을 사용하여 더 많은 버튼을 읽고 2 페이지 발췌 록을 표시하고 더 많은 버튼을 읽은 최신 블로그 게시물을 1 개 표시합니다. 다음은 wordpress 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

내가 조사 할 때, 그것은 당신의 문장을 하나의 단어로 취하는 것으로 보인다. 비록 당신이 실제/적절한 데이터를 삽입하면 해결 될 것이라고 생각합니다.

빠른 해결 방법은 CSSp tag에 넣는 것입니다.

word-wrap: break-word;

+0

감사합니다. 결코 이것을 발견하지 못했을 것입니다! –

+0

당신을 도우려는 즐거움 :) Happy Coding !! – Rikesh

1

문제가 데이터베이스에있는 게시물의 실제 내용과 함께 할 코드와 함께 할 작은, 그리고 많은 것 같다.

소스 코드를 검사하면 'test'라는 단어 다음에 &nbsp;, 즉 비 단속 문자가옵니다. 이런 종류의 내용은 말하자면, 예를 들어 표 형식의 데이터를 만들고 한 줄에 성과 이름을 넣을 때 줄 바꿈을 방지하도록 설계된 HTML 엔터티입니다.

Wordpress 관리 영역으로 가서 문제의 게시물을 수정하십시오. WYSIWYG에서 HTML 편집 모드로 변경하고이 파일이 Test test test test test 또는 Test&nbsp;test&nbsp;test&nbsp; 행에 있는지 확인하십시오. 후자 인 경우 Wordpress는 전체 게시물을 하나의 단어로 해석하므로 Wordpress는 발췌 부분에 모든 단어를 포함하지 않아도됩니다. 단어 길이는 기본값 인 55 자로 제한됩니다.

또한 텍스트가 넘치는 이유는 &nbsp; 개체와 관련이 있습니다. 다시 말하지만, 줄이 정상적으로 끊어지지 않으므로 텍스트 줄이 div.section list을 오버플로합니다.