wordpress自定义帖子和单页

时间:2013-09-18 01:28:47

标签: wordpress-theming wordpress

我创建了一个网站,由于某种原因我的自定义帖子类型portfolio.php列出了我的自定义帖子类型中的所有帖子,显示所有这些都很好。但我的single-portfolio.php从我的自定义帖子类型的最新帖子中获取信息?但是去了正确的链接。

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


                        <article class="span12" id="worktit"><h2>Client name: <?php echo get_post_meta(get_the_ID(), 'client', true); ?> </h2></article>
                        <h2>what it looks like...</h2>
                        <article id="workimg"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></article>

                    <ul class="span5 clientinfo" ><!-- connect start -->
                    <h3>Project info: </h3>
                        <li id="client">Client name: <?php echo get_post_meta(get_the_ID(), 'client', true); ?></li>            
                        <li id="link">Project url: <?php echo get_post_meta(get_the_ID(), 'link', true); ?></li>
                        <li id="year">Year produced: <?php echo get_post_meta(get_the_ID(), 'year', true); ?></li>
                        <li id="designer">Project Designer: <?php echo get_post_meta(get_the_ID(), 'designers', true); ?></li>
                        <li id="developer">Project Developer: <?php echo get_post_meta(get_the_ID(), 'developers', true); ?></li>

                    </ul><!-- connect end -->

                    <ul class="span5 skill" ><!-- skills start -->
                    <h3>Technologies used:</h3>
                    <?php $skill = get_the_term_list($post->ID, 'Skills','<li>', '</li><li>', '</li>'); echo strip_tags($skill, '<li></li>');?>
                    </ul> <!-- skills end -->


                    <section class="span12 devneed">
                        <h2>Need a developer for your next project?</h2>
                        <a href="<?php echo get_page_link(12); ?>">Get in touch</a>
                    </section>  

                        </article>

            <?php endwhile; // end of the loop. ?>      

                <?php endif; ?>

这就是我的single-portfolio.php

我的portfolio.php是

                <?php 
                        $loop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => -1, ) ); 
                    ?>
                    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>


                    <section id="portfolioWrap" class="span12">
                        <article class="span12" id="worktit"><h2><a href="<?php the_permalink(); ?>">Client name: <?php echo get_post_meta(get_the_ID(), 'client', true); ?> </h2></a></article>
                        <article  id="skillused">
                        <p>Skills used :
                        <?php $skillused = get_the_term_list($post->ID, 'Skills','<li>', ', ', '</li>'); echo strip_tags($skillused);?></p></article>           
                        <article id="workimg"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></article>
                        </article>
                    </section>

            <?php endwhile; ?>

1 个答案:

答案 0 :(得分:0)

固定。问题是我在页面顶部有一个打开的php标记。