我在常見問題頁面上做一個手風琴,當我打開常見問題頁面我希望它打開最近的帖子,我已經爲它做了一個自定義帖子類型,我不是使用任何手風琴插件,我剛從dreamweaver複製代碼。 我使用的代碼如下: -創建自定義帖子類型帖子打開最新的一個
<?php $recentPosts = new WP_Query(array('showposts' => 1, 'post_type' => 'FAQ'));
while($recentPosts->have_posts()) :
$recentPosts->the_post(); ?>
<div id="Accordion1" class="Accordion" tabindex="0">
<div class="AccordionPanel">
<div class="AccordionPanelTab">
<?php the_title(); ?>
</div>
<div class="AccordionPanelContent"> <?php the_content(); ?> </div>
</div>
<?php endwhile; ?>
</div>
Function.php
add_action('init', 'cptui_register_my_cpt_faq');
function cptui_register_my_cpt_faq() {
register_post_type('faq', array(
'label' => 'FAQ',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'faq', 'with_front' => true),
'query_var' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),
'labels' => array (
'name' => 'FAQ',
'singular_name' => '',
'menu_name' => 'FAQ',
'add_new' => 'Add FAQ',
'add_new_item' => 'Add New FAQ',
'edit' => 'Edit',
'edit_item' => 'Edit FAQ',
'new_item' => 'New FAQ',
'view' => 'View FAQ',
'view_item' => 'View FAQ',
'search_items' => 'Search FAQ',
'not_found' => 'No FAQ Found',
'not_found_in_trash' => 'No FAQ Found in Trash',
'parent' => 'Parent FAQ',
)
)); }
當我使用它被硬編碼這樣這是工作: -
<div id="Accordion1" class="Accordion" tabindex="0">
<div class="AccordionPanel">
<div class="AccordionPanelTab">
title
</div>
<div class="AccordionPanelContent">content </div>
</div>
<div class="AccordionPanel">
<div class="AccordionPanelTab">
title
</div>
<div class="AccordionPanelContent">content </div>
</div>
</div>
如何我可以改變這個嗎?
太好了。正如我看到靜態版本找到了解決方案。有美好的一天。將問題標記爲已解決。所以其他人可以使用它。 –