Beispiel #1
0
    /**
     * the_recommended
     */
    public static function the_recommended()
    {
        if (!class_exists('theme_recommended_post') || !theme_recommended_post::is_enabled()) {
            return false;
        }
        $cache = theme_recommended_post::get_cache();
        if (!empty($cache)) {
            echo $cache;
            unset($cache);
            return;
        }
        $recomms = theme_recommended_post::get_ids();
        if (empty($recomms)) {
            ?>
			<div class="page-tip"><?php 
            echo status_tip('info', ___('Please set some recommended posts to display.'));
            ?>
</div>
			<?php 
            return false;
        }
        global $post;
        $query = new WP_Query(['posts_per_page' => theme_recommended_post::get_item('number'), 'post__in' => $recomms, 'orderby' => 'ID', 'ignore_sticky_posts' => true]);
        ob_start();
        if (have_posts()) {
            ?>
			<div class="home-recomm mod panel">
				<div class="heading">
					<h2 class="title">
						<span class="bg">
						<?php 
            if (class_exists('theme_page_rank')) {
                ?>
							<a href="<?php 
                echo theme_page_rank::get_tabs('recommend')['url'];
                ?>
">
						<?php 
            }
            ?>
						<?php 
            if (theme_recommended_post::get_item('icon')) {
                ?>
							<i class="fa fa-<?php 
                echo theme_recommended_post::get_item('icon');
                ?>
"></i> 
						<?php 
            }
            ?>
						<?php 
            echo theme_recommended_post::get_item('title');
            ?>
						<?php 
            if (class_exists('theme_page_rank')) {
                ?>
							</a>
						<?php 
            }
            ?>
						</span>
					</h2>
					<?php 
            if (class_exists('theme_page_rank')) {
                ?>
						<a href="<?php 
                echo theme_page_rank::get_tabs('recommend')['url'];
                ?>
" class="more"><?php 
                echo ___('more &raquo;');
                ?>
</a>
					<?php 
            }
            ?>
				</div>
				<div class="row">
					<?php 
            foreach ($query->posts as $post) {
                setup_postdata($post);
                self::archive_card_lg(['classes' => 'g-tablet-1-2 g-tablet-1-4', 'lazyload' => false]);
            }
            wp_reset_postdata();
            ?>
				</div>
			</div>
			<?php 
        }
        unset($query, $recomms);
        $cache = ob_get_contents();
        ob_end_clean();
        theme_recommended_post::set_cache($cache);
        echo $cache;
        unset($cache);
    }