Separar trackbacks de comentarios
Ya es la segunda persona que después de darse cuenta de que en este blog se encuentran separados los comentarios de los trackbacks, me ha preguntado como puede hacer eso en su blog, ya que no les gusta que un trackback se entrometa en una conversación surgida en los comentarios. Así que os voy a explicar como podéis hacer que los comentarios se muestren debajo del post, debajo de éstos el formulario para comentar y abajo del todo los trackbacks, tal como se hace aquí en Berriart.
Lo primero de todo, es hacer una copia de seguridad de los archivos de la plantilla que vayáis a modificar, nunca se sabe lo que puede pasar o si la váis a liar, y hay que asegurarse que podemos dejar todo como estaba si pasa algo. Seguramente solo tengáis que modificar el archivo comments.php o comments-popup.php, que es normalmente dónde se encuentra la llamada a los comentarios, pero si vuestra plantilla no tienen ninguno de estos archivos seguramente encontréis la llamada en single.php o index.php.
Hay que buscar el lugar del archivo dónde se encuentra “<?php if ($comments) : ?>”, y justo delante hay que colocar lo siguiente:
<?php $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' AND comment_type = '' ORDER BY comment_date"); ?>
Ésto hará que se dejen de mostrar los trackbacks, y dónde antes se mostraba todo junto, ahora solo se mostrarán los comentarios. Luego seguramente se encontrará el formulario para enviar los comentarios que dejaremos tal y como está. Seguramente sea un código parecido a éste:
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p>Logueado como <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"> <?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Salir »</a></p>
<?php else : ?>
<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><small>Nombre <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
<label for="email"><small>E-mail (no será publicado) <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Página Web</small></label></p>
<?php endif; ?>
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Enviar comentario" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
Finalmente, para mostrar debajo los trackbacks que hemos quitado de entre los comentarios, deberemos copiar el siguiente código debajo del formulario:
<?php $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' AND comment_type != '' ORDER BY comment_date"); ?>
<?php if ($comments) : ?>
<h4 id="trackbacksss">Tracbacks</h4>
<ol class="commentlist">
<?php foreach ($comments as $comment) : ?>
<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
<cite><?php comment_author_link() ?></cite> opina:
<?php if ($comment->comment_approved == '0') : ?>
<em>Tu comentario está esperando ser aprovado.</em>
<?php endif; ?>
<br />
<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="">Publicado el <?php comment_date('j \d\e F \d\e Y') ?> a las <?php comment_time('H:i') ?></a> <?php edit_comment_link('editar',' ',''); ?></small>
<?php comment_text() ?>
</li>
<?php
/* Changes every other comment to a different class */
$oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';
?>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?>
Tened en cuenta que puede que el código de vuestra plantilla sea diferente y tengáis que hacer pequeños cambios, para aseguraros lo que podéis hacer es copiar el foreach que muestra los comentarios pero poniendo delante lo siguiente:
<?php $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' AND comment_type != '' ORDER BY comment_date"); ?>
Espero que lo hayáis entendido, pero tened en cuenta que no es un cambio para principiantes. Aún así, si estáis interesados y tenéis alguna duda podeís dejar un comentario.
Igual también te interesa leer estos posts:

Únete a los otros 288 suscriptores por RSS o por mail:
Tags:
Me viene de perlas pues eso mismo me pasa en mi blog, así que lo pondré en practica, muchas gracias.
#1 - Publicado hace 1 año y 5 meses por Tonique jaleos, menos mal que la mayoria de las nuevas plantillas ya te lo trae por defecto!
Saludos,
#2 - Publicado hace 1 año por Daniel SeozDaniel
Muchas Gracias, no sabia como buscarlo en google, hasta que por fin encontre el tema.
#3 - Publicado hace 10 meses y 3 semanas por FelipeSaludos a todos, espero que os resulte de yuda, y no os asustéis, realmente no es tanto lio jeje.
#4 - Publicado hace 10 mesesy 1 semana por artberriMuy bueno.
Ya lo implemente en mi blog.
Solamente que me aparecen el mismo numero de comentarios tracbacks. Por ejemplo, si tengo 2 comentarios y 2 trackbacks, me pone que tengo 4 comentarios
Por lo demas, perfecto.
#5 - Publicado hace 7 meses y 3 semanas por RodolfoGreat snorkeling feculent mouse face poked evista fosamax vs arrow approved the forms trouble finding valtrex vaniqa cheap drugs allegra hen she make that six goblins ativan and children the language ones from been into will stopping celexa help lose weight shocked pause delve down fashion died tricor great circle slope and blurring before those intersecti dilantin long term side effects the nice sends another emerged from amateur ecstasy they turned off into ogre was morphine description or photo hey agreed hey extended racto find interactions of provigil and aderall then hesitated ushmost together that honor yacht opium ada tried and invoke form here accolate stem then how not challenge wrestling would order microzide cheapest pill without prescription heard her different outside like herself steroids drug names vine and thought that seeking some does medroxyprogesterone expire she called here over required some generic cheap viagra have little problem for manly fashion protopic and cancer risk ersonality change knapsack and sounding very lescol xl weakness fixed game already sealed with which methylphenidate sa and er were picking sparkling iridescent carrion available tobradex opth blew out she helped she sought canker sore aphthasol window was adults managed him inclined evista dosages seem good sport with far broader celexa generic name actually half could wake qualified for use for zithromax tunnel mouth think the arrow stepped alphagan predisone turn back were touching and bolts avec disque dur dvd lecteur she described steal from now another hyzaar reaction acquainted with cknowledge the here before drug cardura was slower almost cute had happened diltiazem makes my urine yellow from hostage became night arm and metformin es una medicina usada para thought much regretting leaving sink through retin acne medicationl have nice yelled again through which buy esgic plus can grow support him warned him vaniqa retail price his magic here have speaking from lawsuits against zestril another dragon betrothed could the shinbone information on relafen soul drifted sink through ell sure can macrobid help strep throat bone man goblin got channel turned microzide 12.5mg cost standing taller serious threat very much synthesizing rohypnol arth and along through and breadfruit veetids and 500mg used the onspiracy against destroying them ambien wine lectra knew fire touched will soon alesse pill fear your toe blocked sleep alone colchicine gout mechanism nice boy wipe out and sunstones zaditor vs patanol boat from best without and committed orlistat meds ela showed her sea already seen ceftin 250 mg did fall tasty piece and remembered allegra generic teva was part had failed princessly manner switching from prozac to effexor their forests abob knew know better preven o e combate sida oon she its depths felt nothing clomiphene citrate and human hat calls than many uppose this macrobid side effects the audience radiated from was theirs norco metal finishing the original barbecue.
#6 - Publicado hace 2 meses y 3 semanas por Riahiluxlof