2017-02-12 3 views
1

Я использую php-код, который я нашел, чтобы считать все изображения в сообщении в wordpress Но после этого нижнего колонтитула кода и боковой панели оба не загружаются. Я не могу это исправить. Вот весь код моей страницы. «Код счетчика» находится в div «photo_gallery_counter». После этого ничего не загружаетсяwordpress footer не загружается после функции

<?php 
    /* 
    Template Name: Страница фотогалереи 
    */ ?> 
    <?php get_header();?> 



    <div class="center-part" style="max-width: 73%;"> 
     <div class="padding-side" style="margin: 0 40px;"> 

     <section class="article"> 
      <div class="h2" style="margin-top: -14px"> 
      <h2>Фотоальбомы</h2></div> 

      <div class="photo_gallery"> 

      <div class="photo_gallery_grid"> 
       <?php if (have_posts()) : 
       $args = array(
       'post_type' => 'fotoalbum', 
       'publish' => true, 

       'paged' => get_query_var('paged'), 
      ); 
       query_posts($args); 
       while (have_posts()) : the_post(); ?> 
       <div class="photo_gallery_album"> 
       <a href="<?php the_permalink(); ?>" class="photo_gallery_link"> 
        <?php 
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large'); 
        ?> 
        <div class="photo_gallery_item" style="background-image: url(<?php echo $thumbnail[0]; ?>);"> 
        <div class="photo_gallery_item_info"> 
         <div class="photo_gallery_title"> 
         <?php the_title(); ?> 
         </div> 
         <div class="photo_gallery_counter"> 
         <?php 

         // Get all the attachments 
         // Get all the galleries in the current post 
         $galleries = get_post_galleries(get_the_ID(), false); 
         // Count all the galleries 
         $total_gal = count($galleries); 
         /** 
         * count all the images 
         * @param array $array The array needed 
         * @return int returns the number of images in the post 
         */ 
         function _get_total_images($array){ 
         $key = 0; 
         $src = 0; 
         while ($key < count($array)){ 
         $src += count($array[$key]['src']); 
         $key++; 
         } 
         return intval($src); 
         } 
         echo _get_total_images($galleries); 
         ?> 
         </div> 
        </div> 
        </div> 
       </a> 
       </div> 
       <?php endwhile;?> 
       <?php endif;?> 
      </div> 
      </div> 
     </section> 
     </div> 

     </div><!-- end of gallery--> 

     <?php get_sidebar('single'); ?> 
     <?php get_footer(); ?> 
+1

Проверили ли вы журналы? Вероятно, код из плагина галереи вызывает любую фатальную ошибку, которая перестает анализировать код. –

+0

нет, ошибок нет в журнале. –

+0

Какие пути с журналами вы проверили? –

ответ

0

Это ошибка php, которая заставляет остальную страницу не загружать точно. Я заметил ошибку в вашем коде, и это, вероятно, виновник, но могут быть и другие. Изменение

$galleries = get_post_galleries(get_the_ID(), false); 

в

$galleries = get_post_gallery(get_the_ID(), false); 

Более подробно о функции здесь: https://codex.wordpress.org/Function_Reference/get_post_gallery
Позвольте мне знать, если это решил его :)

+0

извините, это не сработало. Этот код в порядке, я думаю, потому что он работает. Результаты отображаются на странице. –