edit post link of current post
Support › MB Frontend Submission › edit post link of current post
- This topic has 8 replies, 2 voices, and was last updated 7 years, 3 months ago by
brkard.
-
AuthorPosts
-
December 20, 2017 at 9:11 PM #7913
brkard
ParticipantHi.
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 ?December 21, 2017 at 9:28 AM #7921Anh Tran
KeymasterHi,
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.
December 22, 2017 at 4:55 PM #7943brkard
ParticipantHi. 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.
December 23, 2017 at 3:38 PM #7958Anh Tran
KeymasterI 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 thepost_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>';
December 23, 2017 at 5:27 PM #7962brkard
ParticipantHi. 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=211So "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=211December 25, 2017 at 11:13 PM #7984Anh Tran
KeymasterHi,
The code
home_url( '/page-a/' )
should output the link topage-a
. Can you check the code again? Just to make sure you copy the right code.December 26, 2017 at 2:03 AM #7986brkard
ParticipantHi.
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.
December 26, 2017 at 5:06 PM #7993Anh Tran
KeymasterHi,
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.December 26, 2017 at 5:54 PM #7996brkard
ParticipantThank you very much. It is working now 🙂
-
AuthorPosts
- The topic ‘edit post link of current post’ is closed to new replies.