2017-06-21 9 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 私はこれをどのように修正することができますか? 実際には、この機能を削除したときに投稿やテキストなどの下にこの画像セクションを表示する必要があります。この機能を削除すると問題はありません。

答えて

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とカウントされませんか?ちょうど最後の数行を1ページだけ投稿する方法 –

+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

この場合、ループ上でこれをどのように追加できますか? (申し訳ありませんが、私はワードプレスで盛り上がりです) –

+0

ループは投稿を繰り返すので、あなたのホームページにあなたが望むものはわかりません。 –

+0

ループに必要な最低限のものを編集してみてください。 –

関連する問題