Esempio n. 1
0
function tst_la_rpw_post_meta($meta, $post)
{
    if (!empty($meta)) {
        $meta = tst_related_item_meta($post);
    }
    return $meta;
}
Esempio n. 2
0
function tst_related_posts_list($cpost = null, $tax = 'post_tag', $limit = 5, $args = array())
{
    global $post;
    if (empty($cpost)) {
        $cpost = $post;
    }
    $defaults = array('thumb' => true, 'meta' => true, 'thumb_size' => 'post-thumbnail', 'not_found_msg' => true);
    $args = wp_parse_args($args, $defaults);
    $r_ids = tst_get_related_ids($cpost, $tax, $limit);
    if (empty($r_ids) && $args['not_found_msg']) {
        ?>
		<p><?php 
        _e('No related posts found.', 'tst');
        ?>
</p>
	<?php 
        return;
    }
    $query = new WP_Query(array('post__in' => $r_ids, 'post_type' => 'any'));
    if ($query->have_posts()) {
        ?>
	<ul class="related-posts">
	<?php 
        while ($query->have_posts()) {
            $query->the_post();
            ?>
	<li class="tst-recent-item <?php 
            echo esc_attr($post->post_type);
            if ($args['thumb']) {
                echo ' has-thumb';
            }
            ?>
">

		<?php 
            if (has_post_thumbnail() && $args['thumb'] == true) {
                //thumb
                ?>
			<div class="item-preview"><a href="<?php 
                the_permalink();
                ?>
" rel="bookmark" >
				<?php 
                the_post_thumbnail($args['thumb_size']);
                ?>
			</a></div>
		<?php 
            }
            ?>

			<div class="item-title"><a href="<?php 
            the_permalink();
            ?>
" rel="bookmark"><?php 
            the_title();
            ?>
</a></div>			
			
			<?php 
            //metas
            if ($args['meta']) {
                $meta = tst_related_item_meta($post);
                $sep = frl_get_sep();
                if (!empty($meta)) {
                    ?>
			<div class="item-metadata"><?php 
                    echo implode($sep, $meta);
                    ?>
</div>
			<?php 
                }
            }
            ?>
	</li>
	<?php 
        }
        wp_reset_postdata();
        ?>
	</ul>
<?php 
    } elseif ($args['not_found_msg']) {
        ?>
	<p><?php 
        _e('No related posts found.', 'tst');
        ?>
</p>
<?php 
    }
}