2017-06-21 73 views
-1

我有这个代码的结尾处的内容功能,必须显示在帖子下的东西,它显示在单个页面(帖子详细信息页面) 但在家里什么也没有显示 这里是我的代码WordPress的The_content()返回null家

<?php 
/** 
* The template for content. 
* 
* @package Webdoone 
* @subpackage Ruby 
* @since Ruby 1.1 
*/ 

?> 
<article id="post-<?php the_ID(); ?>" <?php post_class('wow fadeInUp'); ?>> 

     <?php if (has_post_format('gallery')) { ?> 

      <?php $images = get_post_meta($post->ID, '_format_gallery_images', true); ?> 

      <?php 
      if ($images) { ?> 
       <div class="post-img"> 
        <div class="post-type-icon"> 
         <i class="fa fa-picture-o"></i> 
        </div> 
<div class="outter"><div class="inner"> 
        <ul class="bxslider"> 
        <?php 
        foreach ($images as $image) { 
         if ((get_theme_mod('ruby_webdoone_home_layout_settings') === 'home-ful') || (get_theme_mod('ruby_webdoone_archive_layout_settings') === 'arch-ful') || (get_theme_mod('ruby_webdoone_post_layout_settings') === 'post-ful')) { 
          $the_image = wp_get_attachment_image_src($image, 'ruby_webdoone_custom_width'); 
          $the_caption = get_post_field('post_excerpt', $image); ?> 
          <li><img src="<?php echo esc_url($the_image[0]); ?>" 
          <?php 
          if ($the_caption) {?> 
           title="<?php echo esc_attr($the_caption); ?>"<?php 
          }; ?> /></li><?php 
         } else { 
          $the_image = wp_get_attachment_image_src($image, 'ruby_webdoone_full_width'); 
          $the_caption = get_post_field('post_excerpt', $image); ?> 
          <li><img src="<?php echo esc_url($the_image[0]); ?>" 
          <?php 
          if ($the_caption) { ?> 
           title="<?php echo esc_attr($the_caption); ?>"<?php 
          }; ?> /></li><?php 
         }; 
        }; ?> 
        </ul> 
</div></div> 
       </div><?php 
      } 
      } elseif (has_post_format('video')) { ?> 
           <div class="post-img video"> 
            <div class="post-type-icon"> 
             <i class="fa fa-video-camera"></i> 
            </div> 
<div class="outter"><div class="inner"> 
            <div class="fluid-width-video-wrapper" > 
            <?php $ruby_video = get_post_meta($post->ID, '_format_video_embed', true); ?> 
            <?php 

             echo $ruby_video; 

            ?> 
            </div></div></div> 
           </div><?php 
      } elseif (has_post_format('audio')) { ?> 

           <div class="post-img audio"> 
            <div class="post-type-icon"> 
             <i class="fa fa-music"></i> 
            </div> 
            <?php $ruby_audio = get_post_meta($post->ID, '_format_audio_embed', true); ?> 
            <?php 
            if (wp_oembed_get($ruby_audio)) { 
             echo wp_oembed_get($ruby_audio); 
            } else { 
             echo esc_url($ruby_audio); 
            }; ?> 
           </div><?php 
      } else { 
       if (has_post_thumbnail()) { ?> 
             <div class="post-img"> 
             <?php if (is_sticky()) { ?> 
              <div class="post-type-icon"> 
               <i class="fa fa-thumb-tack"></i> 
              </div> 
             <?php } else { ?> 
              <div class="post-type-icon"> 
               <i class="fa fa-pencil"></i> 
              </div> 
             <?php } 

      if (is_home()) { 
       if (!empty($_GET['layout'])) { 
        $layout = $_GET['layout']; 
       } else { 
        $layout = ''; 
       }; 
       if ((get_theme_mod('ruby_webdoone_home_layout_settings') === 'home-ful') || ($layout === 'home-ful')) { ?> 
<div class="outter"><div class="inner"> 

        <a href="<?php echo esc_url(get_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><div class="grid home-full-thumb"><figure class="effect-jazz"><?php the_post_thumbnail('ruby_webdoone_full_width'); ?><figcaption></figcaption></figure></div></a> </div></div><?php 
       } else { ?> 
<div class="outter"><div class="inner"> 
        <a href="<?php echo esc_url(get_permalink()); ?>"><div class="grid home-post-thumb"><figure class="effect-jazz"><?php the_post_thumbnail('ruby_webdoone_content_width'); ?><figcaption></figcaption></figure></div></a> 
</div></div> 
<?php 
       }; 
      } elseif (is_single()) { 
       if (!empty($_GET['layout'])) { 
        $layout = $_GET['layout']; 
       } else { 
        $layout = ''; 
       }; 
       if ((get_theme_mod('ruby_webdoone_post_layout_settings') === 'post-ful') || ($layout === 'post-ful')) { 
        ?> 
      <div class="outter"><div class="inner">  
       <?php the_post_thumbnail('ruby_webdoone_full_width'); ?> 

</div></div> 
       <?php 
       } else { 

       ?> 
    <div class="outter"><div class="inner">  
       <?php the_post_thumbnail('ruby_webdoone_content_width');?> 
</div></div> 
<?php 
       }; 
      } else { 
       if (!empty($_GET['layout'])) { 
        $layout = $_GET['layout']; 
       } else { 
        $layout = ''; 
       }; 
       if ((get_theme_mod('ruby_webdoone_archive_layout_settings') === 'arch-ful') || ($layout === 'arch-ful')) { ?> 
<div class="outter"><div class="inner"> 
        <a href="<?php echo esc_url(get_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('ruby_webdoone_full_width'); ?></a> 
</div></div> 
<?php 
       } else { ?> 
<div class="outter"><div class="inner"> 

        <a href="<?php echo esc_url(get_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('ruby_webdoone_content_width'); ?></a> 
</div></div> 

<?php 
       }; 
      };?> 
        </div><?php 
     }; 
    }; ?> 

    <div class="post-header"> 
     <?php 
     if (is_home()) { ?> 
      <h3><a class="pos-header-title-link" href="<?php esc_url(the_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3><?php 
     } elseif (is_single()) { ?> 
      <h1 class="pos-header-title-link"><?php the_title(); ?></h1><?php 
     } else { ?> 
      <h2><a class="pos-header-title-link" href="<?php esc_url(the_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2><?php 
     } ?> 

     <div class="post-info"> 
      <span class="author"><?php esc_html_e('Author:', 'ruby') ?> <?php the_author_posts_link(); ?> \ </span> 
      <span class="date"><?php the_time(get_option('date_format')); ?> \ </span><span class="cat"><?php the_category(', '); ?></span> 
      <span class="comments-count">\ <?php printf(_nx('1 Comment', '%1$s Comments', get_comments_number(), 'comments number', 'ruby'), number_format_i18n(get_comments_number())); ?></span> 
    </div> 


    </div> 
    <div class="post-data" itemprop="articleBody"><?php 

the_content(); 



    ?> </div> 

</article> 
<?php wp_reset_postdata(); 
?> 

actually content must show this pictures section under posts and text or etc have no problem 我怎样才能解决这一问题? 实际上内容必须显示帖子和文本等下面的图片部分当我删除这个功能,没有问题,wordpress不会显示类似和其他按钮下的帖子。

回答

1

请根据WP文件试试这个

// Declare global $more (before the loop). 
global $more; 
// Set (inside the loop) to display all content, including text below more. 
$more = 1; 
the_content(); 
+0

实际上内容必须显示这张图片的数据(显示在图像后编辑),它显示在单个页面上,但不是家庭 –

+0

所以这不会被视为the_content会呢?如何将最后几行文章贴出单页 –

+0

我不知道,但是当我删除内容时,这个div从所有页面的帖子中删除,这只是显示在单页文章和主页下,甚至没有返回任何内容一个空的div –

1

the_content没有了 “循环”

https://wordpress.stackexchange.com/a/44153/54343

编辑以外的工作:一个类似于这就是 “循环”

<?php 
if (have_posts()) { 
    while (have_posts()) { 
    the_post(); 
    the_content(); 
    } 
} 
?> 
+0

我如何在这种情况下在循环中添加这个? (对不起,我是一个在wordpress mature) –

+0

该循环迭代帖子,我不知道这是你想要在你的主页上吗? –

+0

看到我编辑与循环的最低需要 –