/**
 * Maybe we'll show the latest four posts in a grid!
 *
 * This function is never called in the theme. Its return
 * value can be accessed via the custom "forever-recent-posts"
 * filter.
 *
 * @return array An array of integers representing post IDs.
 * @since Forever 1.0
 */
function forever_recent_four_posts()
{
    // Return early if this feature has been disabled.
    $options = forever_get_theme_options();
    if ('on' != $options['posts_in_columns']) {
        return false;
    }
    if (false === ($latest_post_ids = get_transient('latest_post_ids'))) {
        $args = array('order' => 'DESC', 'ignore_sticky_posts' => 1, 'post__not_in' => forever_featured_posts(), 'posts_per_page' => '4', 'tax_query' => array(array('taxonomy' => 'post_format', 'terms' => array('post-format-status', 'post-format-quote', 'post-format-gallery', 'post-format-image'), 'field' => 'slug', 'operator' => 'NOT IN')));
        $latest = new WP_Query();
        $latest->query($args);
        while ($latest->have_posts()) {
            $latest->the_post();
            $latest_post_ids[] = $latest->post->ID;
        }
        wp_reset_postdata();
    }
    return $latest_post_ids;
}
Пример #2
0
        ?>

					<?php 
        get_template_part('content', get_post_format());
        ?>

				<?php 
    }
    ?>

				<?php 
    forever_content_nav('nav-below');
    ?>

			<?php 
} elseif (!forever_featured_posts() && !$recent) {
    ?>

				<article id="post-0" class="post no-results not-found">
					<header class="entry-header">
						<h1 class="entry-title"><?php 
    _e('Nothing Found', 'forever');
    ?>
</h1>
					</header><!-- .entry-header -->

					<div class="entry-content">
						<p><?php 
    _e('It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'forever');
    ?>
</p>
Пример #3
0
/**
 * Filter the home page posts, and remove any featured post IDs from it. Hooked
 * onto the 'pre_get_posts' action, this changes the parameters of the query
 * before it gets any posts.
 *
 * @global array $featured_post_id
 * @param WP_Query $query
 * @return WP_Query Possibly modified WP_query
 */
function forever_home_posts($query = false)
{
    // Bail if not home, not a query, not main query.
    if (!is_home() || !is_a($query, 'WP_Query') || !$query->is_main_query()) {
        return $query;
    }
    $featured = forever_featured_posts();
    $recent = apply_filters('forever-recent-posts', false);
    // Bail if no featured posts.
    if (!$featured && !$recent) {
        return $query;
    }
    // Exclude featured posts from the main query.
    $query->query_vars['post__not_in'] = array_merge((array) $featured, (array) $recent);
    return $query;
}