Skip Navigation

[Resolved] Edit post link not working with custom post status

This thread is resolved. Here is a description of the problem and solution.

Problem: The "edit post link" doesn't appear if the post has a custom post status.

Solution: Use a custom filter to extend the edit post link to post statuses other than "publish":

function extend_editable_post_statuses( $allowed_post_statuses, $form_id ) {
      
    $allowed_post_statuses = array( 'publish', 'needs-revision' );
  
    return $allowed_post_statuses;
}
add_filter( 'toolset_filter_edit_post_link_publish_statuses_allowed', 'extend_editable_post_statuses', 10, 2 );

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

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by mikaelD 4 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1399085

I am trying to:

Conditionally show two different edit forms depending on the status of a post. I am using a custom post status.

I expected to see:

The edit post link change based on the status of the post.

Instead, I got:

When my condition is based of the custom post status, the edit link does not show at all. When I use a standard post status in the condition it works fine. This seems to only occur for the 'edit post link' shortcode.

If I use the custom post status as a conditional that is just use to display basic text it works as expected.

This works:

[wpv-conditional if="( '[wpv-post-status]' eq 'needs-revision' )"]
    	<p>Some random text</p>
[/wpv-conditional]

This doesn't work:

[wpv-conditional if="( '[wpv-post-status]' eq 'needs-revision' )"]
    	[toolset-edit-post-link content_template_slug='form-edit-profile-conditional' class="btn"]Edit My Profile[/toolset-edit-post-link]
[/wpv-conditional]
#1399203
toolsetexample.jpg

Update on this.

It isn't the condition that is the issue.

It seems that the toolset-edit-post-link shortcode does not work when the post in the loop has a custom post status.

You can see I have included my custom post status in the View loop filters.

If I change the post status to "Pending", "Draft" or "Publish" it the Post Edit Link shows up on the front-end view. If I change the post status to one of my custom ones "Needs Revision" or "Draft (Preview Mode)", the Post Edit Link does not show on the front-end.

#1399261

Hi, yes it turns out that the edit post link depends on a "publish" status. If you'd like to extend that to include custom post statuses, there is a custom filter available:

function extend_editable_post_statuses( $allowed_post_statuses, $form_id ) {
     
    $allowed_post_statuses = array( 'publish', 'needs-revision' );
 
    return $allowed_post_statuses;
}
add_filter( 'toolset_filter_edit_post_link_publish_statuses_allowed', 'extend_editable_post_statuses', 10, 2 );

You can add other status slugs to the allowed post statuses array as a comma-separated list. Let me know if you have additional questions about that.

#1400797

My issue is resolved now. Thank you!