Skip Navigation

[Gelöst] Repeating image field and parent posts

This support ticket is created vor 8 Jahre, 4 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 5 Antworten, has 2 Stimmen.

Last updated by Glenn vor 8 Jahre, 3 Monate.

Assisted by: shekhar.

Author
Artikel
#355718

I am trying to find a way to work with multiple images for a custom post type (assigned to a child post)

I've created a custom post type and added this as a child to another custom post type. I added a repeating-image-field to this child cpt. Set it to non-visible in the parent CPT since this is not possible ("Repeating fields should not be used in child posts.").

I'm looking for a way to:
- be able to add multiple images to this child-cpt
or
- be able to indicate to which parent an entry for this child-cpt belongs (in the dashboard).
For example be able to suffix the title of the child entry with the title of the parent post
I've tried https://toolset.com/forums/topic/want-to-show-more-custom-post-fields-in-dashboard/ but I can't select the parent CPT to show up as a column.

Thank you in advance! 🙂

#355837

shekhar
Supporter

Hi there,

Thank you for contacting Toolset support.

Could you please explain the problem a bit more. Are you trying to add images by using CRED forms or just by going to the backend? If you can include a screenshot that shows what you are doing and the error, it can greatly clarify the problem and let us help you faster.

I will wait for your feedback.

Thanks

#356270
Schermafbeelding 2015-12-30 om 09.41.37.png
Schermafbeelding 2015-12-30 om 09.42.51.png
Schermafbeelding 2015-12-30 om 09.43.11.png
Schermafbeelding 2015-12-30 om 09.43.56.png

Hi, thank you for your reply.

I've recreated the situation in a discover-wp site.

I've created 2 custom post types: Buildings and Rooms. I've also created a custom field group for the Rooms CPT (Roomdetails).

The first screenshot shows the message "Repeating fields should not be used in child posts. Types will update all field values.". To correct this, I've selected which fields should be shown (screenshot 2). In that case, I can correctly save the Building with the child rooms (without losing the data). However, when looking at the Rooms overview page there are rooms with the same title and I can not easily identify to which parent (in my case "Building) a particular room belongs.

Workaround for now: use the edit button in the "Post Relationship" tab to edit the appropriate child post.
If anyone has a better way of dealing with this, I'd love to hear that. And maybe it will be an idea for a future version of Types to be able to see the parent post details in some way.

P.s: let me know if you need the link to the discover-wp site.

#356395

shekhar
Supporter

Hi there,

Thank you for getting back to us.

Please post the details of discover-wp site too. I have enabled the private form for you below the comment box.

Thanks

#356514

shekhar
Supporter

Hi there,

Thank you for getting back to us.

Currently their is only one options as you mentioned to click the edit button to edit the child post. but you can achieve this by using custom code:

add_filter('manage_review_posts_columns', 'manage_review_columns');
add_action('manage_review_posts_custom_column', 'print_review_column', 10, 2);

function manage_review_columns($existing_columns) {
  $existing_columns['test_parent'] = 'Parent Posts';
  return $existing_columns;
}

function print_review_column($column_name, $post_id) {
  if( $column_name == 'test_parent' )
  {
  	global $post;
  	$id =  get_post_meta($post_id, '_wpcf_belongs_book_id', true );
    echo '<a href="'. get_edit_post_link($id).'" target="_blank">'. $id .'</a>';
  }
}

Note:
1) Please change the review with the child post slug.
2) Change the "book" of _wpcf_belongs_book_id to your parent CPT slug.

Please let me know if the above solution works for you, I look forward to your reply!

Thanks

#356569

Hello shekhar,

Thank you for reply.

This solution works indeed, I've got some minor adjustments:

$mcf = types_get_field_meta_value( 'mycustomfield', $id );
echo '<a href="' . get_edit_post_link($id) . '" target="_blank">' . get_the_title($id) . '</a> (' . $mcf . ')';

This code works and displays the title of the parent post and the value of a custo field for that parent post.
The $mcf variable contains the value stored in the database, but how can I display the full text for this instead of just the value?
For example display "Alabama" instead of the value in the database (AL).

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.