主页上的事件顺序颠倒

时间:2014-05-03 作者:Frantumn

我在颠倒出现在我的homepage. 我希望他们在下一个事件出现在顶部。我已尝试修改索引中的代码。php就在have_posts() 正如一些教程所建议的那样,但它在处理事件时的效果似乎与处理帖子时的效果不同。

我用于事件的插件是The Events Calendar.

我已经包含了代码,以防有人需要它。

我正在使用最新版本的插件,以及最新版本的wordpress。主题以“点”为基础

    <?php $mts_options = get_option(\'point\'); ?>
    <?php get_header(); ?>
    <div id="page" class="home-page">
    <div class="content">
        <div class="article">
            <h3 class="frontTitle">
                        <div class="latest">
                        <?php _e(\'Upcoming events\',"mythemeshop"); ?>           
                        </div></h3>
    <?php   $j=0; $i =0;    if (have_posts()) : while (have_posts()) : the_post();?>            
    <article class="<?php echo \'pexcerpt\'.$i++?> post excerpt <?php echo (++$j % 2 == 0) ? \'last\' : \'\'; ?>">
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">
                        <?php if ( has_post_thumbnail() ) { ?> 
                            <?php echo \'<div class="featured-thumbnail">\'; the_post_thumbnail(\'featured\',array(\'title\' => \'\')); echo \'</div>\'; ?>
                        <?php } else { ?>
                            <div class="featured-thumbnail">
                                <img src="<?php echo get_template_directory_uri(); ?>/images/nothumb.png" class="attachment-featured wp-post-image" alt="<?php the_title(); ?>">
                            </div>
                        <?php } ?>
                        <div class="featured-cat"><?php $category = get_the_category(); echo $category[0]->cat_name; ?></div>
                    </a>
                    <header>                        
                        <h2 class="title">
                            <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a>
                        </h2>


                    </header><!--.header-->
                    <div class="post-content image-caption-format-1">
                        <p>
                            <?php echo mts_excerpt(29);?>
                            <span class="readMore"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow"><?php _e(\'Read More\',\'mythemeshop\'); ?></a></span>
                        </p>
                    </div>
                </article>
            <?php endwhile; else: ?>
                <div class="no-results">
                    <h5><?php _e(\'No results found. We apologize for any inconvenience, please hit back on your browser or use the search form below.\', \'mythemeshop\'); ?></h5>
                    <?php get_search_form(); ?>
                </div><!--noResults-->
            <?php endif; ?>
            <!--Start Pagination-->
            <?php if ( isset($mts_options[\'mts_pagenavigation\']) && $mts_options[\'mts_pagenavigation\'] == \'1\' ) { ?>
                <?php  $additional_loop = 0; global $additional_loop; mts_pagination($additional_loop[\'max_num_pages\']); ?>           
            <?php } else { ?>
                <div class="pagination">
                    <ul>
                        <li class="nav-previous"><?php next_posts_link( __( \'&larr; \'.\'Older posts\', \'mythemeshop\' ) ); ?></li>
                        <li class="nav-next"><?php previous_posts_link( __( \'Newer posts\'.\' &rarr;\', \'mythemeshop\' ) ); ?></li>
                    </ul>
                </div>
            <?php } wp_reset_query(); ?>
            <!--End Pagination-->           
        </div>
        <?php get_sidebar(); ?>
<?php get_footer(); ?>

1 个回复
SO网友:Howdy_McGee

也许可以尝试使用pre_get_posts 编辑订单。

function reverse_order_homepage($query){
    if($query->is_home()){
        $query->set(\'order\', \'DESC\');
    }

    return $query;
}
add_action(\'pre_get_posts\', \'reverse_order_homepage\');

结束

相关推荐

Only Showing Upcoming Events

在此页面的侧栏中:http://lifebridgecypress.org/our-people, 我有一个即将使用此代码的事件列表。。。<ul id=\"upcoming-events\"> <?php $latestPosts = new WP_Query(); $latestPosts->query(\'cat=3&showposts=10\'); ?> <?php while ($latestPos