edit post link of current post

Support MB Frontend Submission edit post link of current post

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #7913
    brkardbrkard
    Participant

    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 ?

    #7921
    Anh TranAnh Tran
    Keymaster

    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.

    #7943
    brkardbrkard
    Participant

    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.

    #7958
    Anh TranAnh Tran
    Keymaster

    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>';
    #7962
    brkardbrkard
    Participant

    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

    #7984
    Anh TranAnh Tran
    Keymaster

    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.

    #7986
    brkardbrkard
    Participant

    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.

    #7993
    Anh TranAnh Tran
    Keymaster

    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.

    #7996
    brkardbrkard
    Participant

    Thank you very much. It is working now 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘edit post link of current post’ is closed to new replies.