Example #1
0
function blox_loop_portfolio($options)
{
    $options = array_merge(array('item_style' => 'default', 'overlay' => 'none', 'thumb' => '', 'class' => '', 'width' => '', 'height' => ''), $options);
    global $post;
    $excerpt_html = '';
    if ($options['item_style'] == 'with_excerpt') {
        $excerpt_html = '<div class="entry-content"><p>' . wp_trim_words(wp_strip_all_tags(do_shortcode(get_the_content())), 20) . '</p></div>';
    }
    $result = '';
    $alt = 'Portfolio Image';
    if ($options['item_style'] == 'alternative') {
        $result = '<div class="post_filter_item ' . $options['class'] . '">
                        <article itemscope itemtype="http://schema.org/BlogPosting" class="entry hover">
                            <div class="entry-media">
                                <div class="entry-hover">
                                    <div class="relative">
                                        <div class="entry-title">
                                            <h2 itemprop="headline">
                                                <a itemprop="url" href="' . get_permalink() . '">' . get_the_title() . '</a>
                                            </h2>
                                        </div>
                                        <ul class="entry-meta list-inline">
                                            <li itemprop="datePublished" class="meta-date">' . date_i18n(get_option('date_format'), strtotime(get_the_date())) . '</li>
                                            <li class="meta-like">' . get_post_like(get_the_ID()) . '</li>
                                        </ul>
                                    </div>
                                </div>
                                <img itemprop="image" src="' . $options['thumb'] . '" alt="' . $alt . '" class="img-responsive" />
                            </div>
                        </article>
                    </div>';
    } else {
        $hover_args = array('overlay' => $options['overlay']);
        if ($options['height'] != '') {
            $hover_args = array_merge(array('width' => $options['width'], 'height' => $options['height']), $hover_args);
        }
        $entry_media = hover_featured_image($hover_args);
        $entry_media = tt_getmeta('portfolio_gallery') != '' ? blox_portfolio_gallery($options) : $entry_media;
        $result = '<div class="post_filter_item ' . $options['class'] . '">
                        <article itemscope itemtype="http://schema.org/BlogPosting" class="entry">
                            ' . $entry_media . '
                            <div class="relative">
                                <div class="entry-title">
                                    <h2 itemprop="headline">
                                        <a itemprop="url" href="' . get_permalink() . '">' . get_the_title() . '</a>
                                    </h2>
                                </div>
                                ' . $excerpt_html . '
                                <ul class="entry-meta list-inline">
                                    <li itemprop="datePublished" class="meta-date">' . date_i18n(get_option('date_format'), strtotime(get_the_date())) . '</li>
                                    <li class="meta-like">' . get_post_like(get_the_ID()) . '</li>
                                </ul>
                            </div>
                        </article>
                    </div>';
    }
    return $result;
}
Example #2
0
    function tt_related_posts($options = array())
    {
        $options = array_merge(array('per_page' => '3'), $options);
        global $post, $smof_data;
        $args = array('post__not_in' => array($post->ID), 'posts_per_page' => $options['per_page']);
        $grid_class = 'col-md-4 col-sm-6 col-xs-12';
        $post_type_class = 'blog';
        $categories = get_the_category($post->ID);
        if ($categories) {
            $category_ids = array();
            foreach ($categories as $individual_category) {
                $category_ids[] = $individual_category->term_id;
            }
            $args['category__in'] = $category_ids;
        }
        // For portfolio post and another than Post
        if ($post->post_type != 'post') {
            $tax_name = 'portfolio_entries';
            //should change it to dynamic and for any custom post types
            $args['post_type'] = get_post_type(get_the_ID());
            $args['tax_query'] = array(array('taxonomy' => $tax_name, 'field' => 'id', 'terms' => wp_get_post_terms($post->ID, $tax_name, array('fields' => 'ids'))));
            if ($options['per_page'] == '4') {
                $grid_class = 'col-md-3 col-sm-6 col-xs-12';
            }
            $post_type_class = 'portfolio';
        }
        if (isset($args)) {
            $my_query = new wp_query($args);
            if ($my_query->have_posts()) {
                $html = '';
                while ($my_query->have_posts()) {
                    $my_query->the_post();
                    $html .= '<div class="' . $grid_class . ' loop-item">
                                <article itemscope="" itemtype="http://schema.org/BlogPosting" class="entry">
                                    ' . hover_featured_image(array('overlay' => 'permalink')) . '

                                    <div class="relative">
                                        <div class="entry-title">
                                            <h2 itemprop="headline">
                                                <a itemprop="url" href="' . get_permalink() . '">' . get_the_title() . '</a>
                                            </h2>
                                        </div>
                                        <ul class="entry-meta list-inline">
                                            <li itemprop="datePublished" class="meta-date">' . date_i18n(get_option('date_format'), strtotime(get_the_date())) . '</li>
                                            <li class="meta-like">' . get_post_like(get_the_ID()) . '</li>
                                        </ul>
                                    </div>
                                </article>
                            </div>';
                }
                echo '<div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <h3 class="related-posts">' . __('Related Posts', 'themeton') . '</h3>
                        <div class="blox-element related-posts ' . $post_type_class . ' grid-loop">
                            <div class="row">
                                <div class="loop-container">' . $html . '</div>
                            </div>
                        </div>
                    </div>
                  </div>';
            }
        }
        wp_reset_query();
    }