コード例 #1
0
    public static function frontend_display(array $args = [], $instance)
    {
        global $post;
        $instance = array_merge(['title' => ___('Author posts'), 'posts_per_page' => 12, 'orderby' => 'random', 'content_type' => 'img'], $instance);
        echo $args['before_title'];
        ?>
			<a href="<?php 
        echo class_exists('theme_custom_author_profile') ? theme_custom_author_profile::get_tabs('works', $post->post_author)['url'] : theme_cache::get_author_posts_url($post->post_author);
        ?>
" title="<?php 
        echo ___('Views more author posts.');
        ?>
">
				<i class="fa fa-file-text"></i> 
				<?php 
        echo sprintf($instance['title'], theme_cache::get_the_author_meta('display_name', $post->post_author));
        ?>
			</a>
			<?php 
        echo $args['after_title'];
        $query = new WP_Query(['posts_per_page' => (int) $instance['posts_per_page'], 'orderby' => $instance['orderby'], 'author' => $post->post_author, 'post_not__in' => [$post->ID], 'ignore_sticky_posts' => true]);
        ?>
		<div class="card-container">
			<?php 
        if ($query->have_posts()) {
            ?>
				<div class="row widget-author-post-<?php 
            echo $instance['orderby'];
            ?>
">
					<?php 
            foreach ($query->posts as $post) {
                setup_postdata($post);
                theme_functions::archive_card_xs(['classes' => 'g-phone-1-2']);
            }
            wp_reset_postdata();
            ?>
				</div>
			<?php 
        } else {
            ?>
				<div class="page-tip not-found">
					<?php 
            echo status_tip('info', ___('No data yet.'));
            ?>
				</div>
			<?php 
        }
        ?>
		</div>
		<?php 
        unset($query);
    }
コード例 #2
0
ファイル: custom-page-cats.php プロジェクト: ClayMoreBoy/mx
    public static function display_frontend()
    {
        $cache = theme_cache::get(__CLASS__);
        if (!empty($cache)) {
            echo $cache;
            unset($cache);
            return;
        }
        ob_start();
        $slugs = self::get_slugs();
        if (empty($slugs)) {
            ?>
<div class="page-tip"><?php 
            echo status_tip('info', ___('No cagtegory yet.'));
            ?>
</div><?php 
            return false;
        }
        global $post;
        ksort($slugs);
        foreach ($slugs as $k => $post_ids) {
            ?>
			<div class="panel-tags-index mod panel">
				<div class="heading">
					<h2 class="title">
						<span class="bg">
							<span class="tx"><?php 
            echo strtoupper($k);
            ?>
</span>
							<small> - <?php 
            echo ___('Initial');
            ?>
</small>
						</span>
					</h2>
				</div>
				<div class="row">
					<?php 
            $query = new WP_Query(array('nopaging' => true, 'post__in' => $post_ids, 'ignore_sticky_posts' => true));
            foreach ($query->posts as $post) {
                setup_postdata($post);
                theme_functions::archive_card_xs(['classes' => 'g-phone-1-2 g-tablet-1-3 g-desktop-1-4']);
            }
            unset($query);
            wp_reset_postdata();
            ?>
				</div>
			</div>
			<?php 
        }
        $cache = ob_get_contents();
        ob_end_clean();
        wp_cache_set(__CLASS__, $cache, null, 86400);
        /** 24 hours */
        echo $cache;
        unset($cache, $slugs);
    }