Themes y Diseño

Foro WordPress » WordPress » Themes y Diseño

Problema con visualizar comentarios. (9 mensajes)

Acerca de este hilo

Tags

  1. xiscomax

    2.0
    Antiguedad: Mar 2010
    Mensajes: 8

    offline

    Publicado hace 2 años
    #

    En mi pagina single.php tengo añadido un código que muestra las ultimas 8 imágenes de campos personalizados pero dicho código parece ser que afecta a la hora de mostrar los comentarios, de forma que en cada entrada muestra todos los comentarios indiferentemente de a que entrada pertenezca.

    Este es mi código single.php haber si alguien da con el posible problema.

    < ?php get_header(); ? >
    < link href="style.css" rel="stylesheet" type="text/css" / >

    < div id="content" >
    < !--single.php-- >

    < !--loop-- >
      < ?php if (have_posts()) : while (have_posts()) : the_post(); $foto = get_post_meta($post- >ID, "foto", $single = true); ? >

            < !--post title-- >
                < h1 id="post-< ?php the_ID(); ? >" >
                  < ?php the_title(); ? >
                < /h1 >

    < div class="postspace2" >
      < /div >
    < !--content with more link-- >
                <img src="< ?php" /> / >
                < ?php the_content('< p class="serif" >Read the rest of this entry &raquo;< /p >'); ? >

                           < !--for paginate posts-- >
                < ?php link_pages('< p ><strong>Pages:</strong> ', '< /p >', 'number'); ? >

            < div id="tags" >Taken by < ?php the_author(); ? > &raquo; Posted on < ?php the_time('F j, Y'); ? > &raquo; Filed in < ?php the_category(', ') ? > &raquo; <a>" rel="bookmark" title="Permanent Link: < ?php the_title(); ? >" >Link</a> < ?php edit_post_link('Edit'); ? > < /div >

    < div class="
    postspace" >
      < /div >

                    < !--all options over and out-- >

    < div id="
    navigation" >    < ?php next_post_link('&laquo; %link |') ? > <a>" >Inicio</a> < ?php previous_post_link('| %link  &raquo;') ? > < /div >

    < !--photos here-- >
    < div id="photos" >
            < ?php $recent = new WP_Query("showposts=8"); while($recent- >have_posts()) : $recent- >the_post();? >
            <a>" >< img style="float:left; margin:0px 4px 20px 4px; width:100px; height:100px; -moz-border-radius: 5px;
     border-radius: 5px; -webkit-border-radius: 5px;" src="< ?php echo get_post_meta($post- >ID, "Thumbnail", true); ? >" alt="
            < ?php the_title(); ? >" / ></a>
            < ?php endwhile; ? >
      < /div >
    < !--photos end-- >

    < !--put comments code here-- >
    < div id="
    comments" >
        < ?php comments_template(); // include comments template ? >
    < /div >

            < !--do not delete-- >
        < ?php endwhile; else: ? >

        Sorry, no posts matched your criteria.

    < !--do not delete-- >
    < ?php endif; ? >

    < !--single.php end-- >
    < /div >

    < !--include footer-- >
    < ?php get_footer(); ? >

    Este es el codigo que muestra el listado.

    < !--photos here-- >
    < div id="photos" >
            < ?php $recent = new WP_Query("showposts=8"); while($recent- >have_posts()) : $recent- >the_post();? >
            <a>" >< img style="float:left; margin:0px 4px 20px 4px; width:100px; height:100px; -moz-border-radius: 5px;
     border-radius: 5px; -webkit-border-radius: 5px;" src="< ?php echo get_post_meta($post- >ID, "Thumbnail", true); ? >" alt="
            < ?php the_title(); ? >" / ></a>
            < ?php endwhile; ? >
      < /div >
    < !--photos end-- >

    Gracias y saludos

  2. rubiomike

    4.0
    Antiguedad: Dic 2009
    Mensajes: 57

    offline

    Publicado hace 2 años
    #

    Hola, si no me equivoco el problema está en el query, no porque esté mal implementado, sino porque al cerrar el bucle, necesitas hacer algunas cosillas más para que funcione el listado más los comentarios.

    La solución yo la encontré aqui

    Espero que te sirva, si tienes alguna duda o no controlas mucho de inglés dímelo y te ayudo con ello.

    Un saludo.

  3. xiscomax

    2.0
    Antiguedad: Mar 2010
    Mensajes: 8

    offline

    Publicado hace 2 años
    #

    El ingles.. gracias al sr.google mas o menos uno se defiende xD bien

    pero ni así eh conseguido entender la solución jeje

  4. rubiomike

    4.0
    Antiguedad: Dic 2009
    Mensajes: 57

    offline

    Publicado hace 2 años
    #

    A ver te inserto yo el código como creo que debería quedar, haz una copia de seguridad y después reemplaza todo el código anterior por:

    < ?php get_header(); ? >
    < link href="style.css" rel="stylesheet" type="text/css" / >

    < div id="content" >
    < !--single.php-- >

    < !--loop-- >
      < ?php if (have_posts()) : while (have_posts()) : the_post();
    $thisPageID = get_the_ID();
    $thisPageID = 'p='.$thisPageID;
    $foto = get_post_meta($post- >ID, "foto", $single = true);

     ? >

            < !--post title-- >
                < h1 id="post-< ?php the_ID(); ? >" >
                  < ?php the_title(); ? >
                < /h1 >

    < div class="postspace2" >
      < /div >
    < !--content with more link-- >
                <img src="< ?php" /> / >
                < ?php the_content('< p class="serif" >Read the rest of this entry &raquo;< /p >'); ? >

                           < !--for paginate posts-- >
                < ?php link_pages('< p ><strong>Pages:</strong> ', '< /p >', 'number'); ? >

            < div id="tags" >Taken by < ?php the_author(); ? > &raquo; Posted on < ?php the_time('F j, Y'); ? > &raquo; Filed in < ?php the_category(', ') ? > &raquo; <a>" rel="bookmark" title="Permanent Link: < ?php the_title(); ? >" >Link</a> < ?php edit_post_link('Edit'); ? > < /div >

    < div class="
    postspace" >
      < /div >

                    < !--all options over and out-- >

    < div id="
    navigation" >    < ?php next_post_link('&laquo; %link |') ? > <a>" >Inicio</a> < ?php previous_post_link('| %link  &raquo;') ? > < /div >

    < !--photos here-- >
    < div id="photos" >
            < ?php $recent = new WP_Query("showposts=8"); while($recent- >have_posts()) : $recent- >the_post();? >
            <a>" >< img style="float:left; margin:0px 4px 20px 4px; width:100px; height:100px; -moz-border-radius: 5px;
     border-radius: 5px; -webkit-border-radius: 5px;" src="< ?php echo get_post_meta($post- >ID, "Thumbnail", true); ? >" alt="
            < ?php the_title(); ? >" / ></a>
            < ?php endwhile; ? >
      < /div >
    < !--photos end-- >

    < !--put comments code here-- >

    < ?php
    $recent = new wp_query($thisPageID);
    while($recent- >have_posts()) :
    $recent- >the_post(); ? >

    < div id="
    comments" >
        < ?php comments_template(); // include comments template ? >
    < /div >

            < !--do not delete-- >
        < ?php endwhile; else: ? >

        Sorry, no posts matched your criteria.

    < !--do not delete-- >
    < ?php endif; ? >

    < !--single.php end-- >
    < /div >

    Dime a ver si te funciona correctamente. Un saludo

  5. xiscomax

    2.0
    Antiguedad: Mar 2010
    Mensajes: 8

    offline

    Publicado hace 2 años
    #

    En la linea

    19 < img src="< ?php" /> / >

    puede que este algo mal?

    luego me causa error en la linea

    57 <!--do not delete-->
    <?php endwhile; else: ?>

    Saludos de nuevo rubiomike y gracias

  6. rubiomike

    4.0
    Antiguedad: Dic 2009
    Mensajes: 57

    offline

    Publicado hace 2 años
    #

    Si, en la línea 19, hay un error porque está incompleta y es debido a que al meter el códgio en este foro, suprime parte de los datos cuando tiene la etiqueta img. Sustituye esa línea por lo que pone en el backup que has hecho.

    En cuanto a lo de la línea 57, no se muy bien por que es, pero prueba a cambiar los dos puntos finales por por punto y coma, si no es por eso, prueba dejando solo el php endwhile.

    Suerte!

  7. xiscomax

    2.0
    Antiguedad: Mar 2010
    Mensajes: 8

    offline

    Publicado hace 2 años
    #

    Obtengo los siguientes errores.

    Parse error: syntax error, unexpected T_ELSE in C:\...\localhost\xampplite\htdocs\...\wp-content\themes\...\single.php on line 65

    65 <?php endwhile; else: ?>

    Sustituyendo los dos puntos finales por punto y coma no causa ningún efecto.

    Eliminando else:?> y dejando solo endwhile.

    Parse error: syntax error, unexpected T_ENDIF in C:\...\localhost\xampplite\htdocs\...\wp-content\themes\...\single.php on line 70

    70 <?php endif; ?>

    Actualmente mi single.php se encuentra así.

    < ?php get_header(); ? >
    < link href="style.css" rel="stylesheet" type="text/css" / >

    < div id="content" >
    < !--single.php-- >

    < !--loop-- >
      < ?php if (have_posts()) : while (have_posts()) : the_post();
    $thisPageID = get_the_ID();
    $thisPageID = 'p='.$thisPageID;
    $foto = get_post_meta($post- >ID, "foto", $single = true);

     ? >

            < !--post title-- >
                < h1 id="post-< ?php the_ID(); ? >" >
                  < ?php the_title(); ? >
                < /h1 >

    < div class="postspace2" >
      < /div >
    < !--content with more link-- >
                <img src="< ?php" /> / >
                < ?php the_content('< p class="serif" >Read the rest of this entry &raquo;< /p >'); ? >

                           < !--for paginate posts-- >
                < ?php link_pages('< p ><strong>Pages:</strong> ', '< /p >', 'number'); ? >

            < div id="tags" >Taken by < ?php the_author(); ? > &raquo; Posted on < ?php the_time('F j, Y'); ? > &raquo; Filed in < ?php the_category(', ') ? > &raquo; <a>" rel="bookmark" title="Permanent Link: < ?php the_title(); ? >" >Link</a> < ?php edit_post_link('Edit'); ? > < /div >

    < div class="
    postspace" >
      < /div >

                    < !--all options over and out-- >

    < div id="
    navigation" >    < ?php next_post_link('&laquo; %link |') ? > <a>" >Inicio</a> < ?php previous_post_link('| %link  &raquo;') ? > < /div >

    < !--photos here-- >

    < div id="photos" >

            < ?php $recent = new WP_Query("showposts=8"); while($recent- >have_posts()) : $recent- >the_post();? >
            <a>" >< img style="float:left; margin:0px 4px 20px 4px; width:100px; height:100px; -moz-border-radius: 5px;
     border-radius: 5px; -webkit-border-radius: 5px;" src="< ?php echo get_post_meta($post- >ID, "Thumbnail", true); ? >" alt="
     < ?php the_title(); ? >" / ></a>
            < ?php endwhile; ? >
      < /div > 

    < !--photos end-- >
    < !--put comments code here-- >

    < ?php
    $recent = new wp_query($thisPageID);
    while($recent- >have_posts()) :
    $recent- >the_post(); ? >

    < div id="
    comments" >
        < ?php comments_template(); // include comments template ? >
    < /div >

            < !--do not delete-- >
        < ?php endwhile; else: ? >

        Sorry, no posts matched your criteria.

    < !--do not delete-- >
    < ?php endif; ? >

    < !--single.php end-- >
    < /div >

    < !--include footer-- >
    < ?php get_footer(); ? >

    Saludos y gracias

    Veo que el foro como mencionaste anteriormente no respeta demasiado los códigos, una gran pena que pase esto en un foro de ayuda y soporte, espero que den una solución pronto.

    Por si es de mejor ayuda aquí puedes descargar mi single.php

    http://rapidshare.com/files/365321995/single.php.html

  8. xiscomax

    2.0
    Antiguedad: Mar 2010
    Mensajes: 8

    offline

    Publicado hace 2 años
    #

    Eh añadido un

    <?php endwhile; ?>

    despues de la linea

    <?php $recent = new wp_query($thisPageID); while($recent->have_posts()) : $recent->the_post(); ?>

    Y parece ser que funciona, estaria bien hecho?

  9. rubiomike

    4.0
    Antiguedad: Dic 2009
    Mensajes: 57

    offline

    Publicado hace 2 años
    #

    Hola, en principio si te funciona todo correctamente, si, estaría bien.

    Un saludo

Responder

Debes Identificarte para publicar.

Foro WordPress » WordPress » Themes y Diseño