Comme on le doc-u en œuvre dans le journal de mise à jour du site, for a while we had a problem with our theme where it wasn’t possible to reply to a comment so that the reply would appear correctly in a threaded way. We have no fixed this problem, but have been left with a significant number of comments which really need editing so it is easier to see what they are in reply to. With a standard wordpress install this requires going into the database and editing there, which is very tedious. Instead, we’ve used some simple functions to add an option to the comment-edit admin page, to set the comment parent there. Eventually this will be developed into a proper plugin to enable this functionality. For now the code is below, il suffit d'ajouter à la functions.php de votre thème
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | function comment_parent_meta_box() { add_meta_box( 'comment_parent', __( 'Parent ID' ), 'comment_parent_cb', 'comment', 'normal', 'high' ); } add_action( 'add_meta_boxes_comment', 'comment_parent_meta_box' ); function comment_parent_cb( $comment ) { $parent = get_comment_meta( $comment->comment_ID, 'comment_parent', true ); wp_nonce_field( 'parent_comment_update', 'parent_comment_update', false ); ?> <input type="text" value="<?php echo get_comment_meta( $comment-/>comment_ID, 'comment_parent', true ) ?>" name="comment_parent" id="comment_parent" /> < ?php } function comment_parent_edit( $comment_id ) { if( ! isset( $_POST['parent_comment_update'] ) || ! wp_verify_nonce( $_POST['parent_comment_update'], 'parent_comment_update' ) ) return; if( isset( $_POST['comment_parent'] ) ) update_comment_meta( $comment_id, 'comment_parent', esc_attr( $_POST['comment_parent'] ) ); } add_action( 'edit_comment', 'comment_parent_edit' ); |
Nous avons trouvé cet utile? S'il vous plaît ne laissez-nous savoir en laissant tomber un commentaire ci-dessous. Si vous souhaitez vous abonner s'il vous plaît utiliser le lien d'abonnement dans le menu en haut à droite. Vous pouvez également partager avec vos amis en utilisant les liens sociaux ci-dessous. À votre santé.
Laisser un commentaire