-
AuthorPosts
-
February 8, 2018 at 11:58 pm #910053
Hi,
first: I am not a coder … and so I have awkwardly added
edit_post_link(__(' <div style="color: #ff0000; font-weight: bold; font-size: 11px;"> EDIT</div>'));
in loop-index.php and other files, to have a red “edit” link at the bottom of each post and page, built with ALB and others not built with ALB, at the frontend.
I have somewhere found a function, to add such an “edit” link in a “function”, that I can add in the functions.php instead of adding my snippet in lots of other files, but I don’t find the source of this function anymore.
Any idea what to place in the functions.php for this edit-link please?
(P.S.: I do not use the WordPress toolbar, it is distracting me.)
Thank you.February 10, 2018 at 5:28 pm #910573Hey Chris,
Try checking out this thread: https://kriesi.at/support/topic/edit-page-link/
Hope this is the information that you need :)Best regards,
NikkoFebruary 10, 2018 at 5:56 pm #910585yes, that is the method, I have done: adding the snippet to these files.
But someone here in the forum gave a user a snippet for the adding it to the functions.php, so that automatically an edit link is added to each post, page and other custom post types.
Unfortunately I cannot find this anymore here …February 12, 2018 at 1:15 am #910855Hi,
Can you try adding this php code at the bottom of functions.php:
add_filter('the_content', 'mycontent'); add_filter('avf_template_builder_content', 'mycontent'); function mycontent( $content ) { if( is_singular() ) { $content = $content . '<p><a href="' . get_edit_post_link( get_the_ID(), 'Edit this page') . '">Edit this page</a></p>'; } return $content; }
Hope this helps.
Best regards,
NikkoFebruary 12, 2018 at 5:11 pm #911190That’s it, thanks, Nikko, just one thing:
it works fine at posts:
But on PAGES (that I create mostly with ALB), it appears twice:
(Info: My PAGES are – not all, but mostly – created with ALB,
and all my posts are NOT created with ALB, if this is helpful to know)How can I modify the code snippet, so that “edit this page” only appears once on ALB PAGES?
Thank you.February 13, 2018 at 5:40 am #911525Hi,
I see, can you replace the code I gave to this one:
add_filter('the_content', 'mycontent'); add_filter('avf_template_builder_content', 'mycontent'); function mycontent( $content ) { if( is_singular() ) { $class = 'page-edit'; if (strpos($content, $class) == false) { $content = $content . '<p class="page-edit"><a href="' . get_edit_post_link( get_the_ID(), 'Edit this page') . '">Edit this page</a></p>'; } } return $content; }
Let us know if this helps :)
Best regards,
NikkoFebruary 13, 2018 at 11:08 pm #911975Works perfectly, thank you very much, Nikko:
February 14, 2018 at 4:22 am #912083Hi,
You’re very much welcome, we are glad to help! Thanks for using Enfold :)
Best regards,
Nikko -
AuthorPosts
- The topic ‘How to add "edit" link for pages/posts in the functions.php?’ is closed to new replies.