2016-08-11 2 views
0

내 테마에는 정렬 가능한 포트폴리오가 있습니다. 그리고 그 안에 포트폴리오 태그 이미지를 표시하고 싶습니다. 이에 대한 플러그인은 this입니다. 그러나 나는 그것을 아주 잘 사용자 정의 할 수 없었다.어떻게하면 Wordpress에서 포트폴리오 이미지를 표시 할 수 있습니까?

게시물의 카테고리 이미지를 표시하고 싶지 않기 때문에 포트폴리오의 태그 이미지를 색인에 표시하고 싶습니다. 이걸로 분명히 할 것 같아. screenshot 스크린 샷에서 볼 수있는이 이미지를 인덱스에서 호출하고 싶습니다. 여기

내 테마 코드입니다 :

<?php 

$query = ff_get_query_for_section(); 
if(!ff_archive_layout_type_test('portfolio', basename(__FILE__))){ 
    return false; 
} 

ff_require_portfolio_archive_helper_before(); 


$numberOfPosts = ($query->get('number-of-posts')) ; 

?> 
      <!-- Filter Section --> 
      <section <?php ff_print_section_attributes($query->get('section-options-sortable section-options'), 'small-section'); //class="small-section bg-gray-lighter"?>> 
       <div class="container relative"> 
        <!-- Works Filter --> 
        <div class="container align-center"> 
         <div class="works-filter mb-0"> 

         <a href="#" class="filter active" data-filter="*"><?php $query->printText('trans-all'); ?></a> 
<?php 
$portfolioTagsArray = array(); 
$portfolioTagsString = ''; 
$postCounter = 0; 
if (have_posts()) { 
    while (have_posts()) { 
     the_post(); 
     $postCounter++; 
      $t = wp_get_post_terms($post->ID, 'ff-portfolio-tag'); 
      if(!empty($t)) foreach ($t as $onePortfolioTag) { 

       if(!isset($portfolioTagsArray[ $onePortfolioTag->slug ])) { 
        $portfolioTagsString .= '<a href="#" class="filter" data-filter=".tag-'.esc_attr($onePortfolioTag->term_id).'">'.ff_wp_kses($onePortfolioTag->name).'</a>'; 
       } 

       $portfolioTagsArray[ $onePortfolioTag->slug ] = $onePortfolioTag; 
      } 
      if($numberOfPosts > 0 && $postCounter >= $numberOfPosts) { 
       break; 
      } 

     } 
    } 

    // Escaped HTML with tags 
    echo $portfolioTagsString; 

?> 
         </div> 
        </div> 
        <!-- End Works Filter --> 

       </div> 
      </section> 
      <!-- End Filter Section --> 


      <!-- Section --> 
      <section <?php ff_print_section_attributes($query->get('section-options'), 'page-section');//class="page-section" id="portfolio"?>> 
       <div class="container relative"> 

        <!-- Works Grid --> 
        <ul class="works-grid work-grid-3 hover-color clearfix" id="work-grid"> 

<?php 
$fwc = ffContainer::getInstance(); 
$postMeta = $fwc->getDataStorageFactory()->createDataStorageWPPostMetas(); 
    rewind_posts(); 
    $postCounter = 0; 
    if (have_posts()) { 
     while (have_posts()) { 
      the_post(); 
      $postCounter++; 
      $currentPostId = $post->ID; 

      require dirname(__FILE__).'/portfolio-archive-one-post.php'; 

      if($numberOfPosts > 0 && $postCounter >= $numberOfPosts ) { 
       break; 
      } 
     } 
    } 
?> 
        </ul> 
        <!-- End Works Grid --> 

        <?php 
        if($query->get('show-pagination')) { 
         ff_bigstream_print_pagination(); 
        } 
        ?> 

       </div> 
      </section> 

      <!-- End Section --> 
<?php 
ff_require_portfolio_archive_helper_after(); 

그리고 난이 파일에이 코드를 추가하려고 :

<?php foreach (wp_get_post_terms($post->ID, 'ff-portfolio-tag') as $cat) : ?> 

<?php z_taxonomy_image($cat->term_id); ?> 
<a href="<?php echo get_term_link($cat->term_id, 'ff-portfolio-tag'); ?>"><?php echo $cat->name; ?></a> 

<?php endforeach; ?> 

하지만 난 성공적인 할 수 없습니다. 도와 주시면 감사하겠습니다. 고마워.

답변

0

get_the_tags() 개체 배열, 게시물에 할당 된 각 태그에 대해 하나의 개체. 이 함수가 The Loop에서 사용되면 아무런 ID도 전달할 필요가 없습니다. 이 함수는 아무 것도 표시하지 않습니다. 개체에 액세스 한 다음 원하는 멤버 변수를 반향 또는 사용해야합니다.

The following example displays the tag name of each tag assigned to the post (this is like using the_tags() , but without linking each tag to the tag view, and using spaces instead of commas):

<?php 
$posttags = get_the_tags(); 
if ($posttags) { 
    foreach($posttags as $tag) { 
    echo $tag->name . ' '; 
    } 
} 
?> 
+0

나는 잘 이해할 수 없었다. 나는 당신의 길을 고려하면서이 수정안을 만들었지 만 그것은 틀렸다. '? tag_id)> name; ?> ' @? HassanALi – Katzenliebe

+0

get_the_tags ($ post_id)이 방법으로 사용하게됩니다. –

+0

죄송합니다, 작동하지 않습니다. – Katzenliebe

관련 문제