Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Filter by category and only a few tags WordPress


Can someone please write up some code based on this to provide me with a way to add a filterable category + tag searhc. It will go in the box on the top right on this site I am doing (I mostly do html + css) I do not want to use a plugin for this. I don't think it's that hard, but I am just not good enough to do it. If you could just post the code and explain what is going and where I should put it, then that would be great.

P.S. It should filter all categories but only 12 tags that i have picked out. Let me know if you need the tag and cat IDs


I have this in my homepage template:

<div id="sort">
<h4>Your hunt for scholarships starts today.</h4>
<form method="get" action="<?php bloginfo('template_url');?>/findscholarships.php" id="sort">
<?php wp_dropdown_categories('show_option_none=Sort by Grade Level&hide_empty=1&child_of=27&orderby=name&name=gradelevel'); ?>
<?php wp_dropdown_categories('show_option_none=Sort by deadline month&hide_empty=1&child_of=26&orderby=name&name=deadline&hierarchical=1'); ?> <input type="submit" value="Search"/> </form>

and this as my findscholarships.php:

<?php require_once('../../../wp-blog-header.php'); if (($_GET[gradelevel] != -1) && ($_GET[deadline] != -1)): $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => 6, 'category__and' => array( $_GET[deadline], $_GET[gradelevel] ), ) ); ?>

<?php else: if ($_GET['gradelevel'] != -1){ header('Deadline:'.get_category_link($_GET['gradelevel'])); } elseif ($_GET['deadline'] != -1){ header('Deadline:'.get_category_link($_GET['deadline'])); } else{ header('Deadline:'.bloginfo('url')); } endif;?>

....but nothing is working yet :c . Any ideas?

Answers (1)


Dbranes answers:

Hi, I guess your dropdown boxes are empty because you have parameters that don't match your setup, i.e.

child_of=26 and child_of=27

and then you need to loop the results from the query_posts.

Jagst3r21 comments:

Sorry my head is spinning :P Is this too complex for you to do if I pm you access to my site?

Dbranes comments:

ok you can pm.