2014-10-03 235 views
0

我讓所有的崗位類型的選擇 選擇柱式當其他選擇列表

<select name="meta-select" id="select_post_types" class="form-control"> 
    <?php foreach ($post_types as $post_type) { ?> 
    <option value="<?php print $post_type; ?>"> <?php print $post_type; ?> </option> 
    <?php } ?> 
</select> 

得到了成功選擇任何崗位類型如何列出一個選擇列表中的所有帖子(如果有的話)

但我想填充所有選擇的帖子類型的帖子,當管理員從頂部選擇選擇。

第二個選擇之後

<select name="meta-select" id="select_post" class="form-control"> 
    <option value=""> </option>'; 

</select> 

回答

0
<?php 
$args = array(
    'public' => true, 
    '_builtin' => false 
); 

$output = 'names'; // names or objects, note names is the default 
$operator = 'and'; // 'and' or 'or' 

$post_types = get_post_types($args, $output, $operator); 
?> 
<select name="meta-select" id="select_post" class="form-control"> 
    <?php 
    foreach ($post_types as $post_type) { 

     ?> 
     <option value="<?php print $post_type; ?>"> <?php print $post_type; ?> </option> 

     <?php 
    } 

    ?> 
</select> 
+0

這將添加自定義文章類型填充現在我想,當用戶從列表中選擇,然後與選擇CTP組裝標題的帖子的任何自定義類型選擇列表在其他選擇列表控件中... – Bilal 2014-10-03 10:48:42