Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Custom field WordPress that will auto-populate from others?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29275
    Luminated
    Member

    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.

    #77371
    Luminated
    Member

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

    Code:
    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:

    #77379
    TheDoc
    Member

    A very interesting case! Nice find on the solution.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.