• Resolved nunsul

    (@nunsul)


    Hi,
    My website shows posts on homepage.
    I would like to add an Edit Post link next to the post date on the archive page and also on single post page.
    Any idea on how to achieve that?
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • AndreeaR

    (@andreearadacina21)

    Hi @nunsul,

    Thank you for using Neve!

    We have a doc explaining how to enable the edit post link for Single Posts – https://docs.themeisle.com/article/1211-how-to-enable-the-edit-post-link-in-neve

    I tested for the archive pages too, and you can add the Edit Post link after the post’s content using the Loop Entry After hook. Here is the code snippet that should help in this regard:

    add_action('neve_loop_entry_after','neve_edit_link');
    function neve_edit_link() {
        edit_post_link(
            sprintf(
            /* translators: %s: Post title. */
                __( 'Edit Post<span class="screen-reader-text"> "%s"</span>', 'neve' ),
                get_the_title()
            ),
            '<span class="edit-link">',
            '</span>'
        );
    }

    Please, let me know if this helps!

    Thread Starter nunsul

    (@nunsul)

    Hi @andreearadacina21,

    Thanks for your answer.
    The code snippet you gave me works fine on the archive page.
    But I can’t add the one on the doc page, I have a critical error.
    The code works if I only save this one but it looks like I can’t have both codes snippets at the same time.

    AndreeaR

    (@andreearadacina21)

    Hi @nunsul,

    The error might appear because the function that I provided above and the function from the doc have the same name.
    We need to use a different name:

    add_action('neve_loop_entry_after','neve_edit_post_link');
    function neve_edit_post_link() {
        edit_post_link(
            sprintf(
            /* translators: %s: Post title. */
                __( 'Edit Post<span class="screen-reader-text"> "%s"</span>', 'neve' ),
                get_the_title()
            ),
            '<span class="edit-link">',
            '</span>'
        );
    }

    Let me know if this helps! I will also mention in the doc.

    AC

    (@purplecodes)

    Themeisle Support

    Hi @nunsul,

    It’s been a while since we have heard from you. We will now be closing this thread if the issue has already been resolved. Kindly open a new thread if you have other questions or concerns.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add an Edit Post link’ is closed to new replies.