我正在使用高级自定义字段。我想要链接这些值(例如,惊险、悬疑等)这样,当用户点击其中一个值时,他们将获得一个过滤后的帖子列表。例如。当他们点击Thriller时,他们将获得Thriller类别中的所有帖子。
到目前为止,我的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 -->对此有解决方案吗?
发布于 2014-01-12 10:04:45
您应该创建一个具有自定义page template的页面。在此模板中,您应该基于通过$_GET参数传递的自定义字段来拉取帖子。
例如:$movies = get_posts(array('meta_key'=>'your_custom_key', 'meta_value'=>$_GET['genre']));
然后,您应该生成适当的链接来访问这个页面,它应该链接到我们的自定义页面,包括我们的$_GET变量中的genre。例如,页面的插件是movies。然后,我们的链接将具有以下结构:/movies/?genre=custom_field_value。
https://stackoverflow.com/questions/21060496
复制相似问题