2013-11-15 29 views
1

我創建了一個自定義的帖子類型的標誌&文本四行連續。我爲此創建了一個工作後存檔,但現在我需要將這些存檔放入另一個頁面,該頁面在需要顯示自定義帖子類型的位置之前和之後都有其他文本和圖像。什麼是正確的方法來做到這一點?如何將自定義帖子類型添加到WordPress的其他文字/圖形頁面?

我的基本頁面模板:

<?php 
/* 
Template Name: Work 
*/ 

get_header(); ?> 

<div id="body"> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
    <?php the_content(); ?> 

    <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?> 
    <?php endwhile; endif; ?> 
</div> 
<?php get_footer(); ?> 

這裏是我試圖讓在頁面模板來顯示歸檔PHP:

<?php 
get_header(); 
?> 

<div class="post"> 

    <?php if (have_posts()) : ?> 

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 

     <?php /* If this is a category archive */ if (is_category()) { 

      ?> 


    <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> 

     <?php } ?> 

<div id="body"><h2>Case Studies</h2></div> 

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

       <div<?php post_class('margin') ?> id="post-<?php the_ID(); ?>"> 


<div class="casestudy"><a href="<?php the_permalink() ?>" class="anchor-hover"> 

    <?php echo get_the_post_thumbnail($post->ID, '180,180'); ?> 
    <span class="details"> 
    <div class="anchor-hover details-h3"><?php the_title(); ?></div> 

<p class="desc"><?php echo get_post($post_id)->post_excerpt; ?></p> 

</span> 
</a> 
    </div> 


<?php endwhile; endif; ?> 
<div class="clear"></div> 

     </div> 

</div> 

<?php get_footer(); ?> 
+0

我推測這段代碼是在Wordpress中? – luiges90

+0

您可以使用高級自定義字段創建_second_內容字段。或者使用簡碼。 – Gant

+0

是的,這是WordPress的 – Chris

回答

-1

這是你看着什麼?

<?php 

$args = array('post_type' => 'YOUR CUSTOM POST TYPE', 'posts_per_page' => THE NUMBER OF POSTS YOU WANT TO DISPLAY);  

$the_query = new WP_Query($args); 

if ($the_query->have_posts()) : 
while ($the_query->have_posts()) : $the_query->the_post(); ?> 

<div<?php post_class('margin') ?> id="post-<?php the_ID(); ?>"> 

<div class="casestudy"><a href="<?php the_permalink() ?>" class="anchor-hover"> 

<?php echo get_the_post_thumbnail($post->ID, '180,180'); ?> 
<span class="details"> 
<div class="anchor-hover details-h3"><?php the_title(); ?></div> 

<p class="desc"><?php the_excerpt(); ?></p> 

</span> 
</a> 
</div> 

<?php endwhile; 
endif; 

// Reset Post Data 
wp_reset_postdata(); 

?> 
+0

好的投票沒有解釋。有些人... –

+0

那不是我,但我嘗試了這個,在我的帖子類型名稱subbing,並且頁面上沒有內容。 – Chris

+0

嗯你有鏈接到你的網頁 –

相關問題