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.

So I have a custom post type (people) with a related custom taxonomy (directory). Instead of editing a person and then choosing the related directory organizations I'd like to "edit" a directory org and choose the people that belong to it. Anyone know of a plugin that allows this?

I could build my own plugin with an interface to do this - looking for opinions here to. Thinking of doing something like:

<?php
//Get all directory orgs                  
$orgs = get_terms("directory");
$count = count($orgs);
$orgtermids = array();
$peopleByOrg = array();
if ( $count > 0 ){
   foreach ( $orgs as $org ) {
     $orgtermids[] = $org->term_id; //Build array of term_ids
     $peopleByOrg[$org->term_id] = array(); //Build an empty array() for each term_id
   }
}
//Get all people currently associated with a directory org 
$myquery['tax_query'] = array(
    array(
        'taxonomy' => 'directory',
        'terms' => $orgtermids,
        'field' => 'term_id',
    )
);
query_posts($myquery);

if (have_posts()) : while (have_posts()) : the_post();
  $postOrgs = get_the_terms($post->ID, 'directory'); //Get directory orgs for this person
  if ( $postOrgs && ! is_wp_error( $postOrgs ) ) { 
    foreach ( $postOrgs as $postOrg ) {
      $peopleByOrg[$postOrg->term_id][$post->ID] = $post; //Store person info with each org it belongs to
    }
  }   
endwhile;
endif;

//Step through and create interface to choose additional people for each directory org
//code TBD  
?>

Any ideas or opinions?


Just thought of a better way to do this by extending the Walker class with a new class based on Walker_Category. I'd have to modify this to create a form where people could be assigned to directory orgs instead of displaying as a list (directory orgs are hierarchical).

share|improve this question

2 Answers 2

I hope I'm understanding your question correctly here. But from what I can understand you'd like a way to select any number of custom post types on the taxonomy edit screen.

You might want to take a look at the Advanced Custom Fields plugin by Elliot Condon. The plugin features a 'Relationship' field type that might be just what you're looking for. The Relationship field allows you to select any number of posts to associate with the term. A single field or a group of custom fields can be applied to a specific taxonomy (rather than to a post editing page) if you wish.

share|improve this answer

I think the "Featured Post Manager" plugin will be closer to what you're looking for:

http://wordpress.org/extend/plugins/featured-post-manager/screenshots/

The language used is somewhat confusing, and it may not work for custom taxonomies (directories) or custom types (people), BUT you can probably take the code and customize it to work for those classes of things instead, as well as updating the language used on the page.

It's mostly a single PHP file, so you'd just have to look at the code ( http://plugins.trac.wordpress.org/browser/featured-post-manager/trunk/fpmngr.php ) and change a couple things from "category" to "directory" (line 81), and "post" to "person/people" (line 108), etc.

share|improve this answer

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.