2010-12-14 34 views
1

我可以在一個名爲Featured Projects的自定義帖子類型中輸出我的所有帖子。 psots的輸出工作正常,自定義元框中的自定義發佈值也是如此。 什麼不輸出是the_permalink()和the_title()。他們只是空白。WordPress the_permalink()什麼都沒輸出

如果您有任何線索我搞砸了,或者我可以檢查,我將不勝感激!

<ul id="projects-nav"> 
    <?php query_posts('post_type=featured-projects&order=ASC&orderby=menu_order&posts_per_page=-1'); ?> 
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
    <?php $agency = get_post_custom_values('agency'); ?> 
    <?php $production = get_post_custom_values('production'); ?> 
    <?php $post = get_post_custom_values('post'); ?> 
    <?php $video_url = get_post_custom_values('video_url_1'); ?> 
    <?php $thumb_url = get_post_custom_values('thumb_url_1'); ?> 
    <li> 
    <a href="<?php the_permalink(); ?>"><img alt="<?php the_title(); ?>" src="<?php echo $thumb_url[0]; ?>" width="185" height="113"></a> 
    <h4><?php the_title(''); ?></h4> 
    <?php the_content(""); ?> 
    <?php if($agency[0] != '') { ?><p>Agency: <?php echo $agency[0]; ?></p><?php } ?> 
    <?php if($production[0] != '') { ?><p>Production: <?php echo $production[0]; ?></p><?php } ?> 
    <?php if($post[0] != '') { ?><p>Post: <?php echo $post[0]; ?></p><?php } ?> 
</li> 
<?php endwhile; endif; ?> 
</ul> 

回答

1

經過很多頭痛和顛簸,並嘗試許多不同的事情。出於某種原因,改變變量的位置似乎使它們都可以工作。 最後的代碼最終被

<ul id="projects-nav"> 
    <?php query_posts('post_type=projects&order=ASC&orderby=menu_order'); ?> 
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
    <?php $thumb_url = get_post_custom_values('thumb_url_1'); ?> 
    <li> 
     <a href="<?php the_permalink(); ?>"><img alt="<?php the_title(''); ?>" src="<?php echo $thumb_url[0]; ?>" width="185" height="113"></a> 
     <h4><?php the_title(''); ?></h4> 
     <?php the_content(''); ?> 

    <?php $agency = get_post_custom_values('agency'); ?> 
    <?php $production = get_post_custom_values('production'); ?> 
    <?php $post = get_post_custom_values('post'); ?> 
     <?php if($agency[0] != '') { ?><p>Agency: <?php echo $agency[0]; ?></p><?php } ?> 
     <?php if($production[0] != '') { ?><p>Production: <?php echo $production[0]; ?></p><?php } ?> 
     <?php if($post[0] != '') { ?><p>Post: <?php echo $post[0]; ?></p><?php } ?> 
    </li> 
    <?php endwhile; endif; ?> 
</ul> 

感謝其他人誰試圖幫助!

0

對於固定鏈接,你可以使用下面這個替代:

而且你嘗試刪除裏面的引號?這可能會搞砸了。

+0

還有什麼替代方案?什麼引號? – LostInQuery 2010-12-14 17:43:41

+0

由h4標記包圍的your_title元素在括號內引號。也許嘗試刪除它們。 – 2010-12-15 02:37:59

0

我想你應該先試着從$agency那裏得到帖子,然後才能試試$production

我不認爲它知道the_title()什麼樣的自定義帖子類型。先用1個自定義帖子類型嘗試整個事情然後添加。我的$ 0.02

+0

自定義帖子值:代理商,製作,視頻,縮略圖和後期製作變量都可以正常工作。這是不輸出任何內容的the_permalink,the_title和the_content。只有一個自定義帖子類型,Featured Projects,這就是query_posts()中查詢的內容 – LostInQuery 2010-12-15 02:03:45

+0

好吧,剛剛意識到the_content()正在輸出,但the_title和the_permalink和get_permalink不起作用。 – LostInQuery 2010-12-15 02:43:20

+0

嘗試在函數的'()'中放入'「」'.. – andrewk 2010-12-15 02:44:51