• Non riesco a mettere i commenti sul mio blog :S

    Nella pagina single.php ho messo il seguente codice:
    <?php comments_template( '', true); ?>
    In quella comments.php questo:

    <?php if ( post_password_required() ) : ?>
    	<p class="nocomments"><?php _e( 'This post is password protected. Enter the password to view comments.', 'traction' ); ?></p>
    	<?php
    	return;
    endif; ?>
    <div id="comments">
    <?php if ( have_comments() ) : ?>
    	<div class="comment-number clear">
    		<span><?php comments_number( __( 'Leave a comment', 'traction' ), __( '1 Comment', 'traction' ), __( '% Comments', 'traction' )); ?></span>
    		<?php if ( comments_open() ) : ?>
    			<a id="leavecomment" href="#respond" title="<?php esc_attr_e( 'Leave a comment', 'traction' ); ?>"> <?php _e( 'Post a comment', 'traction' ); ?></a>
    		<?php endif; ?>
    	</div><!--end comment-number-->
    	<ol class="commentlist">
    		<?php wp_list_comments( 'type=comment&callback=traction_custom_comment' ); ?>
    	</ol>
    
    	<div class="navigation">
    		<div class="alignleft"><?php next_comments_link(__( '&laquo; Older Comments', 'traction' )); ?></div>
    		<div class="alignright"><?php previous_comments_link(__( 'Newer Comments &raquo;', 'traction' )); ?></div>
    	</div>
    	<?php if ( ! empty($comments_by_type['pings']) ) : ?>
    		<h3 class="pinghead"><?php _e( 'Trackbacks & Pingbacks', 'traction' ); ?></h3>
    		<ol class="pinglist">
    			<?php wp_list_comments( 'type=pings&callback=traction_list_pings' ); ?>
    		</ol>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_comments_link(__( '&laquo; Older Pingbacks', 'traction' )); ?></div>
    			<div class="alignright"><?php previous_comments_link(__( 'Newer Pingbacks &raquo;', 'traction' )); ?></div>
    		</div>
    	<?php endif; ?>
    	<?php if ( ! comments_open() ) : ?>
    		<p class="note"><?php _e( 'Comments are closed.', 'traction' ); ?></p>
    	<?php endif; ?>
    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ( ! comments_open() ) : ?>
    
    	<?php endif; ?>
    <?php endif; ?>
    </div><!--end comments-->
    
    <?php
    
    $req = get_option( 'require_name_email' );
    $field = '<fieldset><label for="%1$s" class="comment-field">%2$s</label><input class="text-input" type="text" name="%1$s" id="%1$s" value="%3$s" size="22" tabindex="%4$d" />%5$s</fieldset>';
    comment_form( array(
    	'comment_field' => '<fieldset><label for="comment" class="comment-field"><small>' . _x( 'Comment', 'noun', 'traction' ) . '</small></label><textarea id="comment" name="comment" cols="50" rows="10" aria-required="true" tabindex="4"></textarea></fieldset>',
    	'comment_notes_before' => '',
    	'comment_notes_after' => sprintf(
    		'<p class="guidelines">%3$s</p>' . "\n" . '<p class="comments-rss"><a href="%1$s">%2$s</a></p>',
    		esc_attr( get_post_comments_feed_link() ),
    		__( 'Subscribe to comments', 'traction' ),
    		__( '<strong>Note:</strong> HTML is allowed. Your email address will <strong>never</strong> be published.', 'traction' )
    	),
    	'fields' => array(
    		'author' => sprintf(
    			$field,
    			'author',
    			__( 'Name', 'traction' ),
    			esc_attr( $comment_author ),
    			1,
    			(
    				$req ?
    				'<span>' . __( 'required', 'traction' ) . '</span>' :
    				''
    			)
    		),
    		'email' => sprintf(
    			$field,
    			'email',
    			__( 'Email', 'traction' ),
    			esc_attr( $comment_author_email ),
    			2,
    			(
    				$req ?
    				'<span>' . __( 'required', 'traction' ) . '</span>' :
    				''
    			)
    		),
    		'url' => sprintf(
    			$field,
    			'url',
    			__( 'Website', 'traction' ),
    			esc_attr( $comment_author_url ),
    			3,
    			''
    		),
    	),
    	'label_submit' => __( 'Submit Comment', 'traction' ),
    	'logged_in_as' => '<p class="com-logged-in">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out &raquo;</a>', 'traction' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink() ) ) ) . '</p>',
    	'title_reply' => __( 'Leave a comment', 'traction' ),
    	'title_reply_to' => __( 'Leave a comment to %s', 'traction' ),
    ) );
    
    ?>

    Però quando provo a commentare un mio articolo mi esce questa scritta di errore:

    Warning: call_user_func(custom_comment) [function.call-user-func]: First argument is expected to be a valid callback in /membri/mattiadesiderio/wp-includes/comment-template.php on line 1334

Viewing 1 replies (of 1 total)
  • the error message is possibly referring to these two lines:

    <?php wp_list_comments( 'type=comment&callback=traction_custom_comment' ); ?>

    and:

    <?php wp_list_comments( 'type=pings&callback=traction_list_pings' ); ?>

    you will need something in functions.php of your theme, such as these functions (obviously with real code):

    function traction_custom_comment( $comment, $args, $depth ) {
    //whatever code you need//
    }

    and:

    function traction_list_pings( $comment, $args, $depth ) {
    //whatever code you need//
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Commenti’ is closed to new replies.