2014-02-12 3 views
0

고급 사용자 지정 필드에 유연한 콘텐츠 추가 기능을 사용하고 템플릿 코드에서 간단한 단추 링크의 서식을 지정하는 데 문제가 있습니다. 나는 이런 식으로 뭔가를 사용하는 거라고 일반적으로WP : 고급 사용자 지정 필드 - 유연한 콘텐츠 링크 서식

...

<a class="button" href="<?php the_field('button-link'); ?>"><?php the_field('button-text'); ?></a> 

... 출력에 다음 HTML :

<a class="button" href="http://url.com/the-link">The Text</a> 

하지만 해당 적응하는 방법을 알아낼 수 없습니다 내 유연한 콘텐츠 템플릿 내에서 작업 :

<?php 

if(have_rows('sidebar-content')): 

    while (have_rows('sidebar-content')) : the_row(); 

     if(get_row_layout() == 'text-content'): 

      echo '<div class="sidebar-text-content">'; 
       the_sub_field('flexible-text-content'); 
      echo '</div>'; 

     elseif(get_row_layout() == 'quote'): 

      echo '<blockquote>'; 
       the_sub_field('quote-text'); 
       echo '<span class="quote-source">'; 
        the_sub_field('quote-source'); 
       echo '</span>'; 
      echo '</blockquote>'; 

     elseif(get_row_layout() == 'images'): 

      $image = get_sub_field('image'); 
      echo '<img src="' . $image['sizes']['large'] . '" alt="' . $image['alt'] . '" />'; 

     endif; 

    endwhile; 

endif; 

?> 

의견이 있으십니까? 다음과 같이 미래에이 정보가 도움이 찾을 수 있습니다 사람들을 위해 사전

답변

0

감사, 나는 내 코드를 적용 :

<?php if(have_rows('sidebar-content')): ?> 

    <?php while (have_rows('sidebar-content')) : the_row(); ?> 

     <?php if(get_row_layout() == 'text-content'): ?> 

      <div class="sidebar-text-content"> 
       <?php the_sub_field('flexible-text-content'); ?> 
      </div> 

     <?php elseif(get_row_layout() == 'quote'): ?> 

      <blockquote> 
       <?php the_sub_field('quote-text'); ?> 
       <span class="quote-source"> 
        <?php the_sub_field('quote-source'); ?> 
       </span> 
      </blockquote> 

     <?php elseif(get_row_layout() == 'images'): 

      $image = get_sub_field('image'); 
      echo '<img src="' . $image['sizes']['large'] . '" alt="' . $image['alt'] . '" />'; 

     ?> 

     <?php elseif(get_row_layout() == 'button'): ?> 

      <a class="button" href="<?php the_sub_field('button-link'); ?>"><?php the_sub_field('button-text'); ?></a> 

     <?php endif; ?> 

    <?php endwhile; ?> 

<?php endif; ?> 
관련 문제