Grow your CSS skills. Land your dream job.

Custom field WordPress that will auto-populate from others?

  • # June 7, 2010 at 6:01 pm

    I am in need of creating a custom post type type that will have a custom field that will pull from a list of other post types already created (and subsequently to link to them).

    For example, I am needing to create a post type called "Calendar" that will have a custom field called "Workshop." This field will list all the "Workshops" already created using another custom post type of the same name. The user will be able to easily assign what style of Workshop this Calendar entry is by selecting it off a dropdown, which will be generated dynamically from whatever "Workshops" have been created.

    Does this make sense? It seems like something that has been done before but I haven’t the slightest clue on how to do it.

    # June 8, 2010 at 4:45 pm

    Well, took me around 4-5 hours but I figured this one out. Used Custom Field Template along with this custom wpdb query:

    Code:
    < ?php global $wpdb;
    $items = $wpdb->get_results(“SELECT ID, post_title
    FROM $wpdb->posts
    where post_type = ‘schedule’
    and post_status = ‘publish’
    order by post_date DESC”);
    $i = 0;
    foreach ($items as $item) {
    $values[$i] = $permalink = get_permalink($item->ID);
    $valueLabel[$i] = $item->post_title;
    $i++;
    }
    ?>

    I can explain further if needed! :ugeek:

    # June 8, 2010 at 5:46 pm

    A very interesting case! Nice find on the solution.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".