I’m using theme that have build-in Portfolio tab in the admin panel.
this theme using the portfolio items and portfolio categories instead of the original posts items and categories.
i’ve build a plugin that make list out of the portfolio’s taxonomy – “categories”
<?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;
and wanted to filter all the posts that are not related to the chosen category by the category’s 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>
but no matter what, its always show me the same original posts, and nothing from the portfolio’s posts..
any help would really be appreciated.
UPDATE:
Its now showing every portfolio item but, its showing it only at startup, when i choose category and run search filter, its showing nothing
<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>
I was sending a wrong key, instead of ‘cat’, it should be -> categories