高级自定义字段中的链接流派

问题描述:

我正在使用高级自定义字段。我想链接流派自定义字段的值(例如惊悚片,悬念等),以便当用户点击其中一个值时,它们将获得过滤的帖子列表。例如。当他们点击惊悚片时,他们将获得惊悚片类别中的所有帖子。高级自定义字段中的链接流派

到目前为止我的代码为ACF如下:

<!-- Entry Content Start --> 
     <article <?php post_class('entry clearfix fitvids'); ?>> 
      <div class="inner-post"> 
       <div class="cover"> 
        <div class="post-image"> 
         <?php 
          if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. 
           the_post_thumbnail(); 
          } 
         ?> 
        </div> 
        <div class="custom-fields"> 
         <?php the_meta(); ?> 
         <div class="ad"> 
          <img src="http://lorempixel.com/160/600" alt=""> 
         </div> 
        </div> 
       </div> 
       <div class="the-content"> 
        <?php the_content(); // This is your main post content output ?> 
       </div> 

      </div><!-- /inner-post --> 
     </article><!-- /entry --> 

我希望有一个解决的办法。 在此先感谢。

您应该创建一个自定义页面page template。在此模板中,您应根据通过$_GET参数传递的自定义字段来提取帖子。
例如:$movies = get_posts(array('meta_key'=>'your_custom_key', 'meta_value'=>$_GET['genre']));
然后,您应该生成适当的链接以访问此页面,该链接应链接到我们的自定义页面,包括$_GET变量中的流派。例如页面的slu is是movies。那么我们的链接将具有以下结构:/movies/?genre=custom_field_value

+0

对不起,但我不明白这一点。我对PHP非常了解甚少:( – TBI

+0

你可以试着按照这个[指南](http://www.advancedcustomfields.com/resources/how-to/filter-posts-by-custom-fields/)。 –

+0

我会尽力..谢谢:) – TBI