Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sorry the question might not make sense. I basically have a custom post type called "Projects" and I need to create a way to filter attributes of the project like "name", "type", etc.

For example if I have a project type called airplane, and another project type called airplane. I would want to be able to search for all projects with the name airplane, and display those in the loop.

I have looked into Taxonomies, but I do not know how to use them effectively.

Thanks

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

This is how I did it. If you have your custom post type as "projects", and your category as "airplane".

If you're not planning on using the pre-build loop you would make another one called loop-projects.php. However, it's not necessary.

               <?php
                $args = array(
                    'numberposts'    => 5,
                    'post_type'      => 'projects',
                    'category_name'  => 'airplane');
                query_posts( $args );
                get_template_part( 'loop', 'projects' );
                wp_reset_query();
              ?>
share|improve this answer
    
ok i don't know exactly how to setup categories –  Jeff Feb 18 '11 at 22:32
add comment

If I understand your description right, structure goes like this:

  • custom post type Project;
  • Type is taxonomy associated with Project CPT;
  • Airplane is term in Type taxonomy.

In current WP version you can query for this like (but will get changed in WP 3.1):

query_posts( array( 'post_type' => 'project','type' => 'airplane' ) );

See Taxonomy Parameters in Codex.

share|improve this answer
add comment

Simple as this:

// default filter:  
apply_filters( 'your_filter_name', $val_to_filter );  
// or, make it more specific:   
apply_filters( 'your_filter_name_'.$val_to_filter, $val_to_filter );

You can add this somewhere before your register_post_type call, so it would look like this:

// assuming, you got an $args array to make it easy to handle:  
$args['name'] = apply_filters('your_name_filter', $args['name'] );  
$args['name'] = apply_filters('your_name_filter_'.$args['name'], $args['name']);  
$args['type'] = apply_filters('your_type_filter', $args['type']);  
$args['type'] = apply_filters('your_type_filter_'.$args['type'], $args['type']);    
$name = $args['name'];    
unset($args['name']);  
register_post_type( $name, $args );
share|improve this answer
    
Mpf. Misunderstood you. "Filter" is a biased term in "wordpress language".. –  kaiser Feb 18 '11 at 21:07
    
Biased? How so? –  t31os Feb 19 '11 at 15:11
    
Maybe biased is not the right word (learned it yesterday). I meant with "filter" you would normally associate filters like in the answer above apply_filters. –  kaiser Feb 19 '11 at 21:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.