Problema con comentarios en Wordpress

  • Autor Autor nicorto
  • Fecha de inicio Fecha de inicio
N

nicorto

Lambda
Verificación en dos pasos activada
Hola, en una de mis webs inserté en el single.php un código php para mostrar artículos aleatorios, éste lo puse
en la zona baja y justo sobre el <?php comments_template(); ?> y el problema que tengo es que no se reflejan los comentarios hechos.

El código de los artículos aleatorios es este:
PHP:
<?php
 $random_posts = new WP_Query();
 $random_posts->Query ('orderby=rand&showposts=5');
 while ($random_posts->have_posts()): $random_posts->the_post()
 ?>
 <li>
 <?php
 $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
 if($files){
 $keys = array_keys($files);
 $num=$keys[0];
 $thumb=wp_get_attachment_thumb_url($num);
 print "<img src='$thumb' alt='".get_the_title()."' style='padding: 8px 12px 4px 7px; float: left;' width='70' height='50'/>";
 }else{
 print "<img src='<?php if(has_post_thumbnail()) : the_post_thumbnail(); else : ?>' style='padding: 8px 12px 4px 7px; float: left;' alt='".get_the_title()."' width='70' height='50'/>";
 }
 ?>
 <a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>">
 <?php the_title(); ?></a><br />
 </li>
 <?php endwhile; ?>

y así empieza donde los comentarios:
PHP:
<?php endwhile; endif;?><?php comments_template(); ?><?php comment_form();?>

Abrí un hilo en la zona Wordpress pero creo que debí abrirlo por acá, espero no me llamen la atención por ello.
 
Creo que tu codigo deberia de ser asi:

PHP:
<?php endwhile; endif;?><?php 
 $random_posts = new WP_Query(); 
 $random_posts->Query ('orderby=rand&showposts=5'); 
 while ($random_posts->have_posts()): $random_posts->the_post() 
 ?> 
 <li> 
 <?php 
 $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image"); 
 if($files){ 
 $keys = array_keys($files); 
 $num=$keys[0]; 
 $thumb=wp_get_attachment_thumb_url($num); 
 print "<img src='$thumb' alt='".get_the_title()."' style='padding: 8px 12px 4px 7px; float: left;' width='70' height='50'/>"; 
 }else{ 
 print "<img src='<?php if(has_post_thumbnail()) : the_post_thumbnail(); else : ?>' style='padding: 8px 12px 4px 7px; float: left;' alt='".get_the_title()."' width='70' height='50'/>"; 
 } 
 ?> 
 <a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>"> 
 <?php the_title(); ?></a><br /> 
 </li> 
 <?php endwhile; ?><?php comments_template(); ?><?php comment_form();?>

Prueba si te funciona =)
 
Creo que tu codigo deberia de ser asi:

PHP:
<?php endwhile; endif;?><?php 
 $random_posts = new WP_Query(); 
 $random_posts->Query ('orderby=rand&showposts=5'); 
 while ($random_posts->have_posts()): $random_posts->the_post() 
 ?> 
 <li> 
 <?php 
 $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image"); 
 if($files){ 
 $keys = array_keys($files); 
 $num=$keys[0]; 
 $thumb=wp_get_attachment_thumb_url($num); 
 print "<img src='$thumb' alt='".get_the_title()."' style='padding: 8px 12px 4px 7px; float: left;' width='70' height='50'/>"; 
 }else{ 
 print "<img src='<?php if(has_post_thumbnail()) : the_post_thumbnail(); else : ?>' style='padding: 8px 12px 4px 7px; float: left;' alt='".get_the_title()."' width='70' height='50'/>"; 
 } 
 ?> 
 <a rel="nofollow" href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>"> 
 <?php the_title(); ?></a><br /> 
 </li> 
 <?php endwhile; ?><?php comments_template(); ?><?php comment_form();?>

Prueba si te funciona =)
ok muchas gracias voy a probarlo

- - - Actualizado - - -

Creo que tu codigo deberia de ser asi:

PHP:
<?php endwhile; endif;?><?php 
 $random_posts = new WP_Query(); 
 $random_posts->Query ('orderby=rand&showposts=5'); 
 while ($random_posts->have_posts()): $random_posts->the_post() 
 ?> 
 <li> 
 <?php 
 $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image"); 
 if($files){ 
 $keys = array_keys($files); 
 $num=$keys[0]; 
 $thumb=wp_get_attachment_thumb_url($num); 
 print "<img src='$thumb' alt='".get_the_title()."' style='padding: 8px 12px 4px 7px; float: left;' width='70' height='50'/>"; 
 }else{ 
 print "<img src='<?php if(has_post_thumbnail()) : the_post_thumbnail(); else : ?>' style='padding: 8px 12px 4px 7px; float: left;' alt='".get_the_title()."' width='70' height='50'/>"; 
 } 
 ?> 
 <a rel="nofollow" href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>"> 
 <?php the_title(); ?></a><br /> 
 </li> 
 <?php endwhile; ?><?php comments_template(); ?><?php comment_form();?>

Prueba si te funciona =)

no me funcionó, bueno se me olvidó decir que tengo 2 códigos iguales para que muestre 2 cajas de artículos relacionados, que están así uno detrás del otro

este está arriba
Insertar CODE, HTML o PHP:
<div class="game-info7">
<div class="contenedor">
<div class="random">
<ul>
 <?php
 $random_posts = new WP_Query();
 $random_posts->Query ('orderby=rand&showposts=5');
 while ($random_posts->have_posts()): $random_posts->the_post()
 ?>
 <li>
 <?php
 $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
 if($files){
 $keys = array_keys($files);
 $num=$keys[0];
 $thumb=wp_get_attachment_thumb_url($num);
 print "<img src='$thumb' alt='".get_the_title()."' style='padding: 8px 12px 4px 7px; float: left;' width='70' height='50'/>";
 }else{
 print "<img src='<?php if(has_post_thumbnail()) : the_post_thumbnail(); else : ?>' style='padding: 8px 12px 4px 7px; float: left;' alt='".get_the_title()."' width='70' height='50'/>";
 }
 ?>
 <h3><a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>">
 <?php the_title(); ?></a></h3><br />
 </li>
 <?php endwhile; ?>
</ul>
 </div>
 </div></div>

y este le sigue

Insertar CODE, HTML o PHP:
<div class="game-info8">
<div class="contenedor">
<div class="random">
<ul>
 <?php
 $random_posts = new WP_Query();
 $random_posts->Query ('orderby=rand&showposts=5');
 while ($random_posts->have_posts()): $random_posts->the_post()
 ?>
 <li>
 <?php
 $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
 if($files){
 $keys = array_keys($files);
 $num=$keys[0];
 $thumb=wp_get_attachment_thumb_url($num);
 print "<img src='$thumb' alt='".get_the_title()."' style='padding: 8px 12px 4px 7px; float: left;' width='70' height='50'/>";
 }else{
 print "<img src='<?php if(has_post_thumbnail()) : the_post_thumbnail(); else : ?>' style='padding: 8px 12px 4px 7px; float: left;' alt='".get_the_title()."' width='70' height='50'/>";
 }
 ?>
 <h3><a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title(); ?>">
 <?php the_title(); ?></a></h3><br />
 </li>
 <?php endwhile; ?>
</ul>
 </div>
 </div>
</div>

y luego
Insertar CODE, HTML o PHP:
<?php endwhile; endif;?><?php comments_template(); ?><?php comment_form();?>

muchas gracias por tu ayuda
 
Atrás
Arriba