0

这是我在 wordpress 中的事件模板页面,一次显示 2 个事件,但是当您单击以前的帖子链接以显示较旧的事件帖子时,我在自定义帖子类型中不断收到此 404 页面错误。任何帮助,将不胜感激。这是我的模板页面上的完整代码:

<?php

/*
    Template Name: Events Page
*/

?>

<?php get_header(); ?>

<div id="wrapper">  

    <section id="main-content">

        <div class="signup">
            <a href="#">Sign up for our mailing list</a>
        </div>

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

            <article>
                <?php the_content(); ?> 
            </article>

        <?php endwhile; endif; ?>

        <section id="event-listings">

            <?php
                $args = array(
                    'post_type' => 'events',
                    'posts_per_page' => 2,
                    'paged' => get_query_var('paged')
                );      

                $global_posts_query = new WP_Query($args);
            ?>

            <?php if ($global_posts_query->have_posts()) : while ($global_posts_query->have_posts()) : $global_posts_query->the_post(); ?>

                    <article class="post">
                        <div class="date">
                            <p><?php the_field('date'); ?><br><span class="year"><?php the_field('year'); ?></span></p>
                        </div>              

                        <h2><?php the_field('headline'); ?></h2>

                        <p class="location"><?php the_field('location'); ?> &hearts; <?php the_field('time'); ?></p>

                        <p class="coordinator">Created by: <span class="name"><?php the_field('author'); ?> on <time datetime="<?php echo date(DATE_W3C); ?>" pubdate class="updated"><?php the_time('F jS, Y') ?></time></span></p>

                        <p class="about-content"><?php the_field('about'); ?></p>
                    </article>  

            <?php endwhile; else: ?>

                <p>No events posted at this time.</p>   

            <?php endif; ?>

            <div class="navigation">
                <div class="next-posts"><?php next_posts_link('&laquo; Older Entries', $global_posts_query->max_num_pages) ?></div>
                <div class="prev-posts"><?php previous_posts_link('Newer Entries &raquo;', $global_posts_query->max_num_pages) ?></div>
            </div>              

        </section>                          

    </section><!--End Main Content-->

</div><!--End Wrapper-->

<?php get_footer(); ?>
4

0 回答 0