如何在wordpress中创建预先定制字段的单页?

时间:2016-03-15 09:45:43

标签: wordpress wordpress-plugin wordpress-theming

我用高级自定义字段创建帖子(movie-page.php)我想创建单页(single-movie.php)movie-page.php的每个帖子当我点击每个帖子时它链接到完整细节,但我不能这样做。请帮帮我!!!。谢谢你。

这是我的代码 movie-page.php

<?php
/*
 *  Template Name: Page - Movie Page
 */
?>
<?php get_header(); ?>
<?php 

$posts = get_posts(array(
    'posts_per_page'    => -1,
    'post_type'         => 'movie'
));

if( $posts ): ?>

    <ul>

    <?php foreach( $posts as $post ): 

        setup_postdata( $post )

        ?>
<div class="jol">
            <a href="<?php get_permalink($post->ID); ?>"><?php the_title($post->ID); ?></a>
            <?php get_post_field('descriptionii',$post->ID ); ?>
             <?php the_content() ?>
            <?php the_field("descriptionii") ?>
</div>
        <?php endforeach; ?>

    </ul>

    <?php wp_reset_postdata(); ?>

<?php endif; ?>
<?php get_footer(); ?>

1 个答案:

答案 0 :(得分:1)

 <?php
/*
 *  Template Name: Page - Movie Page
 */
?>
<?php get_header(); ?>
<?php $args = array(
    'posts_per_page'   => -1,
    'post_type'        => 'movie',
    'post_status'      => 'publish',
);
$posts_array = get_posts($args);

foreach ($posts_array as $key => $value) {
    echo "<a href=".$value->guid.">".$value->post_title."</a></br>";
    echo $value->post_content;
}
?>
<?php get_footer();