2015-02-03 2 views
1

저는 WordPress 템플릿을 약간 조정하려고합니다. the_content()가 비어 있으면 기본적으로 아래 코드를 인쇄해야합니다. 현재 비어있는 경우에도 여전히 일명 추악한 흰색 상자가 생성됩니다. 문자열에 코드를 넣고 문자열에 if 문을 수행하려고했지만이 코드를 모두 문자열로 연결하면 저를 위해 작동하지 않습니다. 어떤 제안? 가장 간단한 방법은 내가하고 싶은 일을하거나, 연결된 문자열은 가장 좋은 방법입니까? 그렇다면이 모든 것을 문자열로 묶는 데 도움을 얻을 수 있습니까? 감사!명세서 및 연결 인 경우

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
    <?php if ('' != get_the_post_thumbnail()) : ?> 
     <div class="entry-thumbnail"> 
      <?php the_post_thumbnail('featured-image'); ?> 
     </div><!-- .entry-thumbnail --> 
    <?php endif; ?> 

    <header class="entry-header"> 
     <h1 class="entry-title"><?php the_title(); ?></h1> 
    </header><!-- .entry-header --> 

    <div class="entry-content"> 
     <?php the_content(); ?> 
     <?php 
      wp_link_pages(array(
       'before' => '<div class="page-links">', 
       'after' => '</div>', 
       'pagelink' => '<span class="page-link">%</span>', 
      )); 
     ?> 
    </div><!-- .entry-content --> 
    <?php edit_post_link(__('Edit', 'singl'), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>'); ?> 
</article> 

답변

1
<?php 
$content = get_the_content(); 
if($content != '') { 
    the_content(); 
} ?> 

또는

<?php if($post->post_content != "") { 
    //do something or show content 
}