wp_query没有显示正确的结果

时间:2016-11-08 16:03:09

标签: php jquery wordpress custom-post-type

我有一个名为'电影'的自定义帖子类型在该帖子类型中,我有几个元数据字段,其中一个被称为'已发布'。我要做的是列出电影'发布的帖子'例如yyyy-mm-dd日期格式。这是我到目前为止尝试的代码:         

    <?php $args = array(

        'post_type'         => 'movies',
        'post_status'       => 'publish',
        'orderby'           => 'meta_value_date',
        'meta_key'          => 'released',
        'meta_type'         => 'DATE',          
        'order'             => 'ASC'

        );

    ?>

    <?php $query = new WP_Query( $args ); ?>

    <?php if ( $query->have_posts() ) : ?>

    <?php bd_pagination(); ?>

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

        <div class="panel panel-default panel-body">

            <p class="fa fa-calendar"></p>&nbsp;<?php the_time( 'd-m-Y' ); ?> | <p class="fa fa-clock-o"></p> <?php the_time( 'H:i a' ); ?> |&nbsp;<p class="fa fa-user"></p>&nbsp;<a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author(); ?></a></i> |&nbsp;<p class="fa fa-envelope-o"></p>&nbsp;posted in movies

            <article class="post <?php if ( has_post_thumbnail() ) { ?>has-thumbnail <?php } ?>">

                <div class="post-thumbnail">

                    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'image-poster' ); ?></a>

                </div>

                <article class="post-thumbnail-text">

                        <h4 class="align_Center" style="color:#000; padding-bottom:1em;"><?php the_title(); ?></h4>

                        <?php 

                            $nam = get_post_meta( get_the_ID(), "name", true );
                            $rel = get_post_meta( get_the_ID(), "released", true );
                            $rat = get_post_meta( get_the_ID(), "rating", true );
                            $dur = get_post_meta( get_the_ID(), "duration", true );
                            $gen = get_post_meta( get_the_ID(), "genre", true );
                            $dir = get_post_meta( get_the_ID(), "director", true );
                            $wri = get_post_meta( get_the_ID(), "writer", true );
                            $sta = get_post_meta( get_the_ID(), "stars", true );
                            $sto = get_post_meta( get_the_ID(), "storyline", true );

                        ?>

                            <div class="align_Left">
                                <p><b>Title:</b>&nbsp;<?php echo $nam; ?></p>
                                <p><b>Released:</b>&nbsp;<?php echo $rel; ?></p>
                                <p><b>Rating:</b>&nbsp;<?php echo $rat; ?>/10</p>
                                <p><b>Duration:</b>&nbsp;<?php echo $dur; ?>&nbsp;min</p>
                                <p><b>Genre:</b>&nbsp;<?php echo $gen; ?></p>
                                <p><b>Director/s:</b>&nbsp;<?php echo $dir; ?></p>
                                <p><b>Writer/s:</b>&nbsp;<?php echo $wri; ?></p>
                                <p><b>Stars:</b>&nbsp;<?php echo $sta; ?></p>
                                <p><b>Storyline:</b>&nbsp;<?php echo $sto; ?></p>
                            </div>

                        <?php wp_reset_postdata() ?>  

                    </article>

                </article>

            </div>

希望有人可以提供帮助 史蒂芬

0 个答案:

没有答案