Tagged: , , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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?

    View post on imgur.com

    (P.S.: I do not use the WordPress toolbar, it is distracting me.)
    Thank you.

    #910573

    Hey Chris,

    Try checking out this thread: https://kriesi.at/support/topic/edit-page-link/
    Hope this is the information that you need :)

    Best regards,
    Nikko

    #910585

    yes, 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 …

    #910855

    Hi,

    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,
    Nikko

    #911190

    That’s it, thanks, Nikko, just one thing:

    it works fine at posts:

    View post on imgur.com

    But on PAGES (that I create mostly with ALB), it appears twice:

    View post on imgur.com

    (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.

    #911525

    Hi,

    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,
    Nikko

    #911975

    Works perfectly, thank you very much, Nikko:

    View post on imgur.com

    #912083

    Hi,

    You’re very much welcome, we are glad to help! Thanks for using Enfold :)

    Best regards,
    Nikko

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘How to add "edit" link for pages/posts in the functions.php?’ is closed to new replies.