自定义帖子类型的单个模板不会在WordPress中显示单个帖子

时间:2013-05-16 09:03:39

标签: wordpress custom-post-type

单个mycustompost.php文件中的WordPress代码存在问题。

这是我的代码:

       <div id="contenu">
          <?php global $post;?>
                <?php if (have_posts()) : ?>
                <?php while (have_posts()) : the_post();?>
               <div id="main-inner">
            <?php     
            $terms = get_the_terms( $post->ID, 'projet'); 
            ?> <div id="img-slide">
                   <div id="img-slide-large">
                  <?php
                    $args = array(
                        'order'          => 'ASC',
                        'post_type'      => 'attachment',
                        'post_parent'    => $post->ID,
                        'post_mime_type' => 'image',
                        'post_status'    => null,
                        'orderby'         => 'menu_order',
                        'numberposts'    => -1,

                    );
                    $attachments = get_posts( $args );

                    if ($attachments) {
                        foreach ($attachments as $attachment) {
                            $attachment_url = wp_get_attachment_url( $attachment->ID , 'full' );
                            $image = aq_resize( $attachment_url, 758, 398, true );     //resize & retain image proportions (soft crop)
                            echo '<img src="' . $image . '"/>';
                        }    
                    }
                    ?>
                </div>
                  <div id="img-slide-thumb">
                      <ul id="nav-thumb">
                      <?php
                        if ($attachments) {
                            foreach ($attachments as $attachment) {
                             $attachment_url = wp_get_attachment_url( $attachment->ID , 'full' );
                               $image = aq_resize( $attachment_url, 129, 85, true);       //resize & retain image proportions (soft crop)
                           ?>
                          <li><a href="#"><?php  echo '<img src="' . $image . '"/>'; ?></a>    </li>
                       <?php 
                        } 
                       } ?>
                      </ul>
                   </div>
               </div>
               <div id="infos">
        <?php     echo esc_html( get_post_meta( get_the_ID(), 'date_create_post_type', true ) ); ?>
        <h2><?php the_title() ?></h2>
        <h3><?php     echo esc_html( get_post_meta( get_the_ID(), 'soustitre_create_post_type', true ) ); ?></h3>

        <p><?php the_content(); ?></p>
               </div>
<?php           endwhile;
               endif;
?>               
        </div>

但它显示了我的PROJET海关帖子的完整列表。我不知道为什么会这样做;你能救我吗?

1 个答案:

答案 0 :(得分:0)

问题解决了! 我忘记了我在标题中没有查询 soooo我在标题中添加了它解决了问题。 !