1

Прежде чем я решил опубликовать, я прочитал все, что мог, на этом сайте, с людьми из тех же проблем. Ничто, казалось, не сработало ... Я объясню это как можно лучше, я использую дополнение ACF + Repeater для создания меню ресторана. У меня загружен Bootstrap, чтобы облегчить задачу, я хочу, чтобы у меня было 3 столбца. Это часть HTML и PHP. Я использую Bridge Theme, поэтому мне пришлось изменить класс контейнера Bootstrap на контейнер-acf, потому что он продолжал идти в стиле Bridge вместо этого. Мой конец Цель, если для этого Look Similar To This Вся помощь с благодарностьюИспользуйте PHP и Bootstrap, чтобы сделать столбец содержимого для ACF

Мое предположение: мне понадобится цикл Foreach.

`<?php 
/* 
Template Name: Restaurant Menu Template 
*/ 
get_header(); ?> 
<div class="content-fill-in-menu">HERE</div> 

    <div id="primary" class="content-area"> 

     <main id="main" class="site-main" role="main"> 

     <?php 
     // Start the loop. 
     while (have_posts()) : the_post(); ?> 


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

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

      <div class="entry-content wpb_wrapper container-acf"> 


      <?php if (have_rows('menu_sections')): 
       while (have_rows('menu_sections')): the_row(); ?> 

        <h2 class="section_desc"><?php the_sub_field('section_title'); ?></h2> 

        <?php if (have_rows('section_items')): ?> 

         <?php while (have_rows('section_items')): the_row(); ?> 
        <article class="lmenu"> 
         <ul> 
        <li> 
        <div class="container-acf"> 
         <div class="row"> 
          <div class="col-md-3 item_info"> 

           <img class="dish_pic" src="<?php the_sub_field('dish_pic'); ?>" alt="<?php the_sub_field('dish_name'); ?>"> 
           <h3 class="item_name"><?php the_sub_field('dish_name'); ?></h3> 
           <p class="item_desc"><?php the_sub_field('dish_description'); ?></p> 
           <h4 class="price">$<?php the_sub_field('dish_price'); ?></h4> 
           <span class="separator"></span> 
          </div> 
         </div> 
        </div> 
          </li> 
         </ul> 
        </article> 
         <?php endwhile; ?> 

         </table> 

        <?php endif; ?> 

       <?php endwhile; 
      endif; ?> 


      </div><!-- .entry-content --> 

     </article><!-- #post-## --> 



     <?php endwhile; // End the loop. ?> 

     </main><!-- .site-main --> 

    </div><!-- .content-area --> 
    <div class="content-fill-in-menu">HERE</div> 

<?php get_footer(); ?>` 

ответ

0

Я думаю, что многие из ваших проблем находятся в цикле в поле ретранслятора «section_items». В цикле «while» вы открываете и закрываете контейнер и строку для каждого элемента, поэтому у вас нет рендера в столбцах.

Здесь, в идее изменений, вам нужно открыть строку до начала цикла. Я поставил счетчик ($ я), чтобы возобновить подряд каждые 4 пунктов, чтобы предотвратить проблемы:

<?php if (have_rows('menu_sections')): ?> 
     <?php while (have_rows('menu_sections')): the_row(); ?> 

     <h2 class="section_desc"><?php the_sub_field('section_title'); ?></h2> 
     <?php if (have_rows('section_items')): ?> 

      <?php $i = 1; ?> 
      <div class="row"> 

      <?php while (have_rows('section_items')): the_row(); ?> 
       <div class="col-md-3 item_info"> 
       <article class="lmenu"> 
        <img class="dish_pic" src="<?php the_sub_field('dish_pic'); ?>" alt="<?php the_sub_field('dish_name'); ?>"> 
        <h3 class="item_name"><?php the_sub_field('dish_name'); ?></h3> 
        <p class="item_desc"><?php the_sub_field('dish_description'); ?></p> 
        <h4 class="price">$<?php the_sub_field('dish_price'); ?></h4> 
        <span class="separator"></span> 
       </article> 
       </div><!-- /.col --> 

       <?php 
       if($i == 4){ 
       echo '</div><div class="row">'; 
       $i = 0; 
       } 
       $i++; 
       ?> 
      <?php endwhile; ?> 

      </div><!-- /.row --> 

     <?php endif; ?> 

     <?php endwhile; ?> 
    <?php endif; ?> 
+0

Спасибо, я дам это попробовать и доложить ... ценю помощь – KangOnRails

+0

Спасибо, я передам это попробуйте и отправьте отчет ... Оцените помощь – KangOnRails