Support Forum
Support › MB Frontend Submission › edit post link of current post
Hi.
I need to show edit post link under each post content area. So i need a shortcode that give users ability to edit current post which they are viewing. I need to show something like this: [mb_frontend_form id="front-end-sumbit-form" post_fields= "title, content" post_id="currentpost"] Can we do this with some custom code or with another way ?
Hi,
I've just updated the extension, added "current" value for "post_id" parameter.
I also added dynamic population for shortcode params via query string and hooks. I think it's useful and you can use them somehow. Please refer to the documentation for more details.
Hi. Thanks.
Current value is working...
But i see the whole form under current post if i use the shortcode.
Actually i need a simple link that edits current post in other window or page . if i can do that may be i can make users edit posts in a modal window too
Is this possible to do this ?
If possible and if it is not complicated can you share a code snippet to do this. I will paste the code in single post template.
Thanks.
I got it.
I think you can do like this:
- Create a page for editing the posts (let's say page A) and paste the shortcode to the page content.
- In any post, create a link to the page A, passing the post_id
parameter via query string, like this:
$link = home_url( '/page-a/' );
$link = add_query_arg( 'rwmb_frontend_field_post_id', get_the_ID() );
echo '<a href="', $link, '">Edit this post</a>';
Hi. Thanks for your help.
But with this code
"Page-a" does not outputs in the link...Code outputs current url and rwmb_frontend_field_post_id'
For example: my current page name is: "info-page"
This code outputs like this:
https://example.com/info-page/?rwmb_frontend_field_post_id=211
So "page-a" does not outputs in the link. The edit link url should be like this i think.
https://example.com/page-a/?rwmb_frontend_field_post_id=211
Hi,
The code home_url( '/page-a/' )
should output the link to page-a
. Can you check the code again? Just to make sure you copy the right code.
Hi.
I checked the code again.
Here is the code i pasted:
<?php
$link = home_url( '/page-a/' );
$link = add_query_arg( 'rwmb_frontend_field_post_id', get_the_ID() );
echo '<a href="', $link, '">Edit this post</a>';
?>
And also i have send you site login details for you to check.
Thanks.
Hi,
Sorry, my previous code missed 1 last param. It should be:
$link = add_query_arg( 'rwmb_frontend_field_post_id', get_the_ID(), $link );
I have created an edit page on your site, another meta box for test and add the code to page.php
to display the edit link. Please take a look.
Thank you very much. It is working now 🙂