Skip Navigation

[Resolved] Trouble creating child post edit links

This support ticket is created 6 years, 4 months ago. 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.

This topic contains 1 reply, has 1 voice.

Last updated by laneV 6 years, 4 months ago.

Author
Posts
#1087076

One of my child post types has a repeatable image field. On the parent page I have a link to create that child post to upload images and it works as expected. I need to be able to have a link to edit that child post type too. I wanted to just change the add link to an edit link but I've read that I can only create the edit link while in the loop displaying the images from that child post. Is this correct?

Assuming the above is correct I tried to add the cred_form shortcode to my loop. The images display in a slider. I have 2 content templates that produce the slider:

This first content template is called from the parent page:

<div id="place-images-carousel" class="carousel slide" data-ride="carousel">

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
[wpv-post-body view_template="place-image-slider"]
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#place-images-carousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#place-images-carousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

As you can see this calls the second content template with my loop:

[wpv-for-each field="wpcf-place-image" item='@place-to-place-image.child']
<div class="item">
[types field='place-image' title='%%TITLE%%' alt='%%ALT%%' align='center' height="300" resize='proportional' item='@place-to-place-image.child' class="d-block w-100"][/types]
  <div class="place-image-edit-link">
    [cred_form form='place-image-manager' post='@place-to-place-image.child']
  </div>
</div>
[/wpv-for-each]

What I get is "Form type and post type do not match".

Is this because I've got a for-each going on rather than a wpv-loop? If so, how can I accomplish this with the wpv-loop instead?

I tried to change things up by calling the first content template from a view:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
		[wpv-post-body view_template="place-container-slider"]
        [toolset-edit-post-link content_template_slug="place-image-edit"]Edit Images[/toolset-edit-post-link]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
[wpv-layout-end]

I get the link to work to take me to the edit form, but the slider no longer displays correctly.

For the view, I have the Content Selection set to the child post type with the images, and the Query Filter is set to "Select posts in a Places to Place Images relationship that are related to the Post where this View is shown."

#1087125

I duplicated my first content template within a view and used the second content template. This let me insert the edit link from within the loop. However, something with the view messed up the slider.

So, I punted. I reverted to my original content templates to display my slider. Then added a view that, in a loop, will allow the link to be created to edit the child post with the repeatable image field.

It works, but this seems to be double the work because I'm having to loop through the child post twice.