查询其他页面中的帖子

时间:2013-12-11 22:35:01

标签: php wordpress

我正在为教堂建立一个网站,我想在主页的工作人员页面上显示一个职员简介。在员工页面上,我使用高级自定义字段添加员工档案。它有img,title,name和description字段。

代码结束时。 “home-staff-wrapper”是我想在员工页面显示一个员工档案的地方。请帮忙!!

这是我的主页代码:

<?php
    /* page-homepage.php */
    get_header();
?>
<div id="main-wrapper">
    <div id="home-slider-wrapper">
        <?php if(function_exists('vslider')){ vslider('homepageslider'); }?>
        <div id="home-church-intro">
            <div id="home-intro-content"><?php the_field('church_intro'); ?></div>
        </div>
    </div>
    <div id="home-left-content-wrapper">
        <div id="home-worship-time-wrapper">
            <div id="home-title">Worship Time</div>
            <div id="home-worship-detail">
                <?php if(have_posts()): while(have_posts()): the_post(); ?>
                <?php the_content(); ?>
                <?php endwhile; endif; ?>
            </div>
        </div>
        <div id="home-announcement-wrapper">
            <div id="home-title">Announcement</div>
            <div id="home-announcement-detail"><?php the_field('announcement'); ?></div>
        </div>
    </div>
    <div id="home-right-content-wrapper">
        <div id="home-sermon-wrapper">
            <div id="home-title">Sermon</div>
            <?php $sermon_query = new WP_Query(array('posts_per_page' => 2)); ?>
            <?php if($sermon_query -> have_posts()): while($sermon_query -> have_posts()): $sermon_query -> the_post(); ?>
            <div id="home-sermon-detail">
                <div id="home-sermon-thumbnail-wrapper">
                    <div id="home-sermon-thumbnail"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div>
                </div>
                <div id="home-sermon-title-and-date-wrapper">
                    <div id="home-sermon-title"><?php the_title(); ?></div>
                    <div id="home-sermon-date"><?php the_time('F j, Y'); ?></div>
                </div>
            </div>
            <?php endwhile; wp_reset_postdata(); ?>
            <?php endif; ?>
        </div>
        <div id="home-staff-wrapper">
            <?php //$staff = new WP_Query('page_id = 273'); ?>
            <?php //while($staff -> have_posts()): ?>
            <?php //the_post(); ?>
            <?php //the_content(); ?>
            <?php //endwhile; wp_reset_postdata(); ?>
        </div>
    </div>
</div>
<?php get_footer(); ?> 

0 个答案:

没有答案