• Resolved alx.r89

    (@alxr89)


    Hi, I want to use a different template to show comments (for a single post), in order to add a button/link near the “reply” link, for each comment.

    So I have copied comment-template.php from the wp-includes folder to the “templates” folder of my plugin, in order to edit it without editing the wordpress core files. Then I have added the following lines in my plugin:

    add_filter( 'template_include', array($this, 'pf_comment_template'));

    with the following function:

    function pf_comment_template( $template ) {
    
    		if ( is_single()  ) {
    			$new_template = dirname( __FILE__ ) . '/templates/pf-comment-template.php';
    			if ( '' != $new_template ) {
    				return $new_template ;
    			}
    		}
    
    		return $template;
    	}

    But I get the error:
    Fatal error: Cannot redeclare get_comment_author() (previously declared in ….\wp-includes\comment-template.php:22)

    How can I solve?
    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter alx.r89

    (@alxr89)

    I have solved by another way. I have just hooked a function to ‘edit_comment_link’ filter.

    Thanks anyway

Viewing 1 replies (of 1 total)
  • The topic ‘How override the comment template’ is closed to new replies.