• In Posts 2 Posts, I am trying to create a list of checkboxes using Connection Information. The checkboxes would be created from an array of Custom Post Type titles. The function and P2P registration code I’m starting with is here:

    https://pastebin.com/bj0TiTp1

    Could someone point me in the right direction or tell me what I’m doing wrong?

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jefffassnacht

    (@jefffassnacht)

    To clarify… The above code is located in functions.php. There is a Custom Post Type called ‘color’. I am trying to create a series of checkboxes, one for each of the colors. I’d like that list of colors to change as the ‘color’ CPT entries change.

    So, basically, you want to create 3-way connections: dinnerware <-> page <-> color.

    Theoretically, if you replace this:

    while ( $loop->have_posts() ) : $loop->the_post();
      $colors[] = the_title();
    endwhile;

    with this:

    $colors = scb_list_fold( $loop->posts, 'ID', 'post_title' );

    it should work. The checkboxes would contain the color IDs as values.

    Thread Starter jefffassnacht

    (@jefffassnacht)

    Thank you for the quick response. Using the scb_list_fold statement above, printing $colors to see it’s value returns this:
    Array ( [255] => Clearwater [254] => Celadon [253] => Ginger )
    A single checkbox appears in the P2P admin area but the ids aren’t displaying. Any other suggestions or ideas are greatly appreciated.

    That’s because you’re calling get_colors() in the wrong place.

    Remove $item_colors[] = get_colors(); and replace this:

    'values' => $item_colors

    with this:

    'values' => get_colors()
    Thread Starter jefffassnacht

    (@jefffassnacht)

    Works perfectly. Thank you for the guidance, and thank you for the fantastic P2P plug-in! Much appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Posts 2 Posts] Use Array of CPT titles in Connection Information’ is closed to new replies.