如何以子弹形式显示自定义相关帖子

时间:2015-09-19 08:43:24

标签: php

我正在使用相关帖子的自定义字段插件来显示我选择的相关帖子。我想以子弹形式显示相关的帖子列表。但我被困在这里请帮我。相关帖子的PHP代码是

<?php  
$posts = get_field('related_posts'); 
if ($posts) { ?>
    <h3 class="related">Related posts</h3>
    <p>
    <?php foreach($posts as $post) { setup_postdata($post); ?>
        <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br/>
    <?php } //End for each loop
    wp_reset_postdata(); //Restores WP post data ?>
    </p>
    <hr />
<?php } //End if ?>

提前感谢。

1 个答案:

答案 0 :(得分:0)

if ($posts) { 
?>
    <style>
      ul.related-list {
         list-style-type: circle;
      }
    </style>
    <h3 class="related">Related posts</h3>
    <ul class="related-list">
        <?php 
         foreach($posts as $post) { 
             setup_postdata($post); 
             ?>
             <li>
                <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
             </li>
         <?php 
         } //End for each loop
         ?>
    </ul>
    <hr />
<?php 
wp_reset_postdata(); //Restores WP post data 
} //End if