-1
我使用的主題,具有集結在管理面板組合標籤排序。 這個主題使用投資組合項目和投資組合類別,而不是原來的帖子項目和類別。PHP的WordPress插件分類類別和職位
我建立一個插件,使列表出來的投資組合的分類法 - 「類別」
<?php $portfolio_cats = get_terms('Categories', $args); ?>
<?php foreach ($portfolio_cats as $cat) { echo "<option value = '".$cat->name."'>".$cat->name."</option>"; } ?> </select> <input style = "height: 35px;
,並希望過濾所有不是由類別的ID與所選類別的職位。
<input style = "height: 35px;
padding: 10px 45px;" type = "submit" value = "הצג" /> </form>
<table class="widefat" style = "margin: 0 auto;width: 908px;">
<thead>
<tr>
<th>Category</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php
$category_id = get_cat_ID(''.$_POST['filter'].'');
$q = 'cat=' . $category_id;
query_posts($q);
if (have_posts()) : while (have_posts()) : the_post(); ?>
<tr> <td> <?php echo $_POST['filter']; ?> </td> <td> <a href="<?php the_permalink();?>"><?php the_title(); ?></a> </td> </tr>
<?php endwhile; endif; ?>
</tbody>
</table>
但不管如何,它總是給我相同的原帖,並從投資組合的帖子沒什麼..
任何幫助將真正理解。
UPDATE: 其現在顯示的每個投資組合項目,但它的顯示只在啓動時它,當我選擇類別和運行搜索過濾器,其深藏不露
<input style = "height: 35px;
padding: 10px 45px;" type = "submit" value = "הצג" /> </form>
<table class="widefat" style = "margin: 0 auto;width: 908px;">
<thead>
<tr>
<th>Category</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php
$category_id = $_REQUEST['filter'];
/* $q = 'cat=' . $category_id; */
query_posts(array ('cat' => $category_id, 'posts_per_page' => -1, 'post_type' => 'portfolio'));
if (have_posts()) : while (have_posts()) : the_post(); ?>
<tr> <td> <?php echo $_POST['filter']; ?> </td> <td> <a href="<?php the_permalink();?>"><?php the_title(); ?></a> </td> </tr>
<?php endwhile; endif; ?>
</tbody>
</table>
哪種類型後是什麼?另外第一個代碼示例中的'var_dump($ args)'是什麼? – hakre 2012-08-07 23:24:35
後類型是投資組合。 $ args實際上並不是什麼,它可以被替換爲默認屬性 – 2012-08-07 23:25:58
嘗試在'$ q'字符串中添加'post_type = portfolio'。否則,'query_posts'將會在默認的post-type(posts)中查找。 – hakre 2012-08-07 23:37:01