Example #1
0
/** Compact post item **/
function tst_compact_post_item($cpost, $show_thumb = true, $tax = 'category')
{
    if (is_int($cpost)) {
        $cpost = get_post($cpost);
    }
    if ($tax == 'auctor') {
        $author = tst_get_post_author($cpost);
        $name = $author ? $author->name : '';
        $avatar = $show_thumb && $author ? tst_get_author_avatar($author->term_id) : '';
    } else {
        //category
        $cat = get_the_terms($cpost->ID, $tax);
        $name = isset($cat[0]) ? $cat[0]->name : '';
        $avatar = $show_thumb ? tst_get_default_author_avatar() : '';
    }
    ?>
	<div class="tpl-related-post"><a href="<?php 
    echo get_permalink($cpost);
    ?>
">
	
	<div class="mdl-grid mdl-grid--no-spacing">
		<div class="mdl-cell mdl-cell--9-col mdl-cell--5-col-tablet mdl-cell--4-col-phone">
			<h4 class="entry-title"><?php 
    echo get_the_title($cpost);
    ?>
</h4>
			
		<?php 
    if ($show_thumb) {
        ?>
	
			<div class="entry-author pictured-card-item">
				<div class="author-avatar round-image pci-img"><?php 
        echo $avatar;
        ?>
</div>
					
				<div class="author-content card-footer-content pci-content">
					<h5 class="author-name mdl-typography--body-1"><?php 
        echo apply_filters('tst_the_title', $name);
        ?>
</h5>
					<p class="post-date mdl-typography--caption"><time><?php 
        echo get_the_date('d.m.Y.', $cpost);
        ?>
</time></p>
				</div>
				
			</div>	
		<?php 
    } else {
        ?>
			<div class="entry-author plain-card-item">
				<h5 class="author-name mdl-typography--body-1"><?php 
        echo apply_filters('tst_the_title', $name);
        ?>
</h5>
				<p class="post-date mdl-typography--caption"><time><?php 
        echo get_the_date('d.m.Y.', $cpost);
        ?>
</time></p>				
			</div>	
		<?php 
    }
    ?>
		</div>
		
		<div class="mdl-cell mdl-cell--3-col mdl-cell--3-col-tablet mdl-cell--hide-phone">
		<?php 
    $thumb = get_the_post_thumbnail($cpost->ID, 'thumbnail-landscape', array('alt' => __('Thumbnail', 'tst')));
    if (empty($thumb)) {
        $thumb = tst_get_default_post_thumbnail('thumbnail-landscape');
    }
    echo $thumb;
    ?>
		</div>
	</div>	
	
	</a></div>
<?php 
}
Example #2
0
function tst_get_author_avatar($author_term_id)
{
    $avatar = get_term_meta($author_term_id, 'auctor_photo', true);
    return $avatar ? wp_get_attachment_image($avatar, 'avatar') : tst_get_default_author_avatar();
}