Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

Errores de validación W3C en un Theme de WordPress

Estas en el tema de Errores de validación W3C en un Theme de WordPress en el foro de WordPress en Foros del Web. Hola a todos. Soy estudiante principiante de programación y mis razonamientos pueden estar intrínsecamente errados. Tengo una plantilla de WordPress "Ecommerce Theme" instalada en localhost ...
  #1 (permalink)  
Antiguo 21/03/2011, 13:58
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Errores de validación W3C en un Theme de WordPress

Hola a todos.
Soy estudiante principiante de programación y mis razonamientos pueden estar intrínsecamente errados.

Tengo una plantilla de WordPress "Ecommerce Theme" instalada en localhost (127.0.0.1) que me arroja un error cada vez que le añado una nueva entrada o post.
Es un problema acumulativo; cada vez que añado una entrada me da dos errores y una advertencia de validación.
Mi teoría es que el problema debe de estar en el archivo anida la generación de post index.php.

A continuación una linea de error del validador, luego el código fuente correspondiente y al final el archivo index.php.

A ver si alguien fuese tan amable de indicarme qué elemento sobra o falta en el código.
Lo más explícito posible, no tengo ni idea de lenguaje PHP.

Muchas gracias por la respuesta.
Un saludo.

P.D.:
Por cierto que los permalinks (enlaces permanentes) en modo local sólo me acepta la opción por defecto.
Para todas las demás no me reconoce el modo de codificar la URL.
En la página remota no tengo tal problema, supongo que será normal.

ERROR VALIDACIÓN EN LÍNEA 170
Cita:

# Error Line 170, Column 78: ID "post-17" already defined

…="bookmark" title="Entrada 7"><h3 id="post-17">Entrada 7</h3><img src="" alt="…

An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).

# Info Line 169, Column 26: ID "post-17" first defined here

<div id="post-17" class="thumbnail">

# Error Line 170, Column 86: document type does not allow element "h3" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

…rk" title="Entrada 7"><h3 id="post-17">Entrada 7</h3><img src="" alt="Entrada …

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

CÓDIGO FUENTE DEL ERROR EN LINEA 170
Cita:

169 <div id="post-17" class="thumbnail">


170 <a href="http://localhost/wp/?p=17" rel="bookmark" title="Entrada 7"><h3 id="post-17">Entrada 7</h3><img src="" alt="Entrada 7 " /></a>

171 <p><a href="http://localhost/wp/?category_name=sin-categoria" title="Ver todas las entradas en Sin categoría" rel="category">Sin categoría</a></p>

172 </div>

ARCHIVO INDEX.PHP (Interlineado modificado para mayor claridad)
Cita:

<!--include sidebar-->

<?php include(TEMPLATEPATH."/l_sidebar.php");?>

<div id="content">

<!--index.php-->

<?php if (have_posts()) : while (have_posts()) : the_post(); // the loop ?>

<div id="post-<?php the_ID(); ?>" class="thumbnail">

<a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a>

<p><?php the_category(', ') ?></p>
</div>

<?php endwhile; // end of one post ?>

<!-- Previous/Next page navigation -->
<div class="page-nav">
<div class="nav-previous"><?php previous_posts_link('&laquo; Previous Page') ?></div>
<div class="nav-next"><?php next_posts_link('Next Page &raquo;') ?></div>
</div>

<?php else : // do not delete ?>

<h3>Page Not Found</h3>
<p>We're sorry, but the page you are looking for isn't here.</p>
<p>Try searching for the page you are looking for or using the navigation in the header or sidebar</p>

<?php endif; // do not delete ?>


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

<!--include footer-->
<?php get_footer(); ?>
  #2 (permalink)  
Antiguo 21/03/2011, 14:08
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Errores de validación W3C en un Theme de WordPress

Estas repitiendo el id el cual deberia ser único, deberias cambiarlos, un ejemplo, en vez de ser todos:

Código PHP:
Ver original
  1. post-<?php the_ID();  ?>

podria ser:

Código PHP:
Ver original
  1. post-title-<?php the_ID();  ?>
  2. post-thumb-<?php the_ID();  ?>
  3. post-<?php the_ID();  ?>

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #3 (permalink)  
Antiguo 21/03/2011, 14:54
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Tema movido desde PHP a WordPress
  #4 (permalink)  
Antiguo 21/03/2011, 16:10
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Hola de nuevo.
Muchas gracias amigo Master.
Casi aciertas el pleno, pero nos falta la otra mitad.

Modifiqué exitosamente el que pone

Código PHP:
Ver original
  1. post-title-<?php the_ID();  ?>

Sin embargo el de la miniatura "Thumbnail" no he tenido suerte con él.
He probado las siguientes combinaciones:

Código PHP:
Ver original
  1. post-thumb-<?php the_ID();  ?>
  2. post-thumbnail-<?php the_ID();  ?>
  3. post-Thumbnail-<?php the_ID();  ?>

Pero ninguna de las tres combinaciones me ha dado éxito.

¿En qué archivo habría que mirar para hacerlo exacto?

Creo que el meollo del asunto está en editar correctamente esta lineas del index.php

Código PHP:
Ver original
  1. <div id="post-<?php the_ID(); ?>" class="thumbnail">

Gracias por la ayuda.

P.D.:
La lista de los archivos de la plantilla más significativos.
El post no me permitía más, pero si es necesario abro otro y pego el resto.


Archive.php
Cita:
<?php get_header(); ?>
<!--include sidebar-->
<?php include(TEMPLATEPATH."/l_sidebar.php");?>

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

<?php if (have_posts()) : // the loop ?>

<h1><?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>

<?php /* If this is a category archive */ if (is_category()) { ?>
<?php echo single_cat_title(); ?>

<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
Archive for <?php the_time('F jS, Y'); ?>

<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
Archive for <?php the_time('F, Y'); ?>

<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
Archive for <?php the_time('Y'); ?>

<?php /* If this is a search */ } elseif (is_search()) { ?>
Search Results

<?php /* If this is an author archive */ } elseif (is_author()) { ?>
Author Archive

<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
Blog Archives

<?php } //do not delete ?>

</h1>

<?php while (have_posts()) : the_post(); // the loop ?>

<div id="post-<?php the_ID(); ?>" class="thumbnail">
<a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a>
<p><?php the_category(', ') ?></p>
</div>

<?php endwhile; //end one post ?>

<!-- Previous/Next page navigation -->
<div class="page-nav">
<div class="nav-previous"><?php previous_posts_link('&laquo; Previous Page') ?></div>
<div class="nav-next"><?php next_posts_link('Next Page &raquo;') ?></div>
</div>

<?php else : //do not delete ?>

<h3>Page Not Found</h3>
<p>We're sorry, but the page you are looking for isn't here.</p>
<p>Try searching for the page you are looking for or using the navigation in the header or sidebar</p>

<?php endif; //do not delete ?>


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

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


Comments.php

Cita:
<?php // Do not delete these lines
if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');

if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
?>

<p class="nocomments">This post is password protected. Enter the password to view comments.<p>

<?php
return;
}
}

/* This variable is for alternating comment background */
$oddcomment = 'odd';
$trackback_check = "true";
?>

<!-- You can start editing here. -->

<div id="comments">

<?php if ($comments) : ?>

<h4 class="comments">Customer Reviews</h4>

<!--the bgein of one comment-->
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>

<div class="<?php if($oddcomment) { echo $oddcomment; } else echo 'even'; ?>" id="comment-<?php comment_ID() ?>">

<div class="comment-head">
By <?php comment_author_link() ?> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?>
</div>

<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em><br />
<?php endif; ?>

<?php comment_text() ?>

</div>

<?php /* Changes every other comment to a different class */
if ('odd' == $oddcomment) $oddcomment = '';
else $oddcomment = 'odd';
?>

<?php } /* End of is_comment statement */ ?>
<?php endforeach; /* end for each comment */ ?>

<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>

<?php if ($trackback_check == "true") { // some sloppy php to get the <h4></h4> and <ul> to display ?>
<h4>Trackbacks</h4>
<ul>
<?php } //end trackback_check if ?>

<li id="comment-<?php comment_ID() ?>">
<strong><?php comment_author_link() ?></strong>
</li>
<?php $trackback_check = "false"; ?>

<?php } ?>
<?php endforeach; ?>

<?php if ($trackback_check == "false") { // if there was at lease 1 trackback, then close the ul ?>
</ul>
<?php } //end trackback_check if ?>

<?php else : // this is displayed if there are no comments so far ?>

<?php if ('open' == $post->comment_status) : //If comments are open, but there are no comments ?>

<?php else : // comments are closed ?>

<p>Comments are closed.</p>

<?php endif; ?>
<?php endif; ?>

<div id="respond" class="postspace2">&nbsp;</div>

<?php if ('open' == $post->comment_status) : ?>

<h4 class="respond">Review this Product</h4>

<?php if ( get_option('comment_registration') && !$user_ID ) : ?>

<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>

<?php else : ?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<?php if ( $user_ID ) : ?>
<p>Logged in as <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">Logout &raquo;</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>Name <?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>Mail (will not be published) <?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>Website</small></label></p>

<?php endif; ?>

<p><textarea name="comment" id="comment" cols="42" rows="10" tabindex="4"></textarea></p>

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>

<?php do_action('comment_form', $post->ID); ?>

</form>

<?php endif; // If registration required and not logged in ?>

<?php endif; // if you delete this the sky will fall on your head ?>

</div> <!--end comments div-->


functions.php
Cita:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Top Tag'));
register_sidebar(array('name'=>'Feature Left'));
register_sidebar(array('name'=>'Feature Right'));
register_sidebar(array('name'=>'Bottom Left Sidebar','before_widget' => '','after_widget' => '','before_title' => '<h2>','after_title' => '</h2>',));
register_sidebar(array('name'=>'Bottom Middle Sidebar','before_widget' => '','after_widget' => '','before_title' => '<h2>','after_title' => '</h2>',));
register_sidebar(array('name'=>'Bottom Right Sidebar','before_widget' => '','after_widget' => '','before_title' => '<h2>','after_title' => '</h2>',));
register_sidebar(array('name'=>'Left Sidebar','before_widget' => '','after_widget' => '','before_title' => '<h2>','after_title' => '</h2>',));
?>
<?php
//Custom Header Image Code -- from the WordPress.com API
define('HEADER_TEXTCOLOR', ''); //doesn't matter
define('NO_HEADER_TEXT', true ); //don't mess with the header text
define('HEADER_IMAGE', '%s/images/logo.jpg'); // %s is theme dir uri
define('HEADER_IMAGE_WIDTH', 1150);
define('HEADER_IMAGE_HEIGHT', 95);

function ecommerce_header_style() {
?>
<style type="text/css">
#header {
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
background: url(<?php header_image(); ?>) bottom left no-repeat;
}
</style>

<?php }
function ecommerce_admin_header_style() {
?>
<style type="text/css">
#headimg {
display: block;
margin: 0px; padding: 0px;
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
background: url(<?php header_image(); ?>) top left no-repeat;
}
#headimg h1, #headimg #desc {
display: none;
}
</style>

<?php }
add_custom_image_header('ecommerce_header_style', 'ecommerce_admin_header_style'); //Add the custom header
?>
  #5 (permalink)  
Antiguo 21/03/2011, 16:35
Avatar de Omegakenshin  
Fecha de Ingreso: junio-2010
Ubicación: Costa Rica
Mensajes: 156
Antigüedad: 13 años, 10 meses
Puntos: 22
Respuesta: Errores de validación W3C en un Theme de WordPress

Salu2 tranzorx, has probando con

Código PHP:
the_post_thumbnail(); 
Aqui esta la información oficial

para que veas el uso y los requisitos para usarlo correctamente

Última edición por webosiris; 21/03/2011 a las 22:36
  #6 (permalink)  
Antiguo 21/03/2011, 17:40
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Gracias por la respuesta veloz.
He probado a poner "éso" en el "index.php", pero no me ha funcionado porque según trato de adivinar, al asunto es algo más complicado.

Según el link, hay otro link que nos lleva a "add_theme_support", y hay que hacer una modificación el el archivo "functions.php", y en mi caso habría que usar la semántica:

Código PHP:
Ver original
  1. <?php add_theme_support( $feature); ?>

que en mi caso $feature creo que nos daría algo así:

Código PHP:
Ver original
  1. <?php add_theme_support('post-thumbnails'); ?>

Mi archivo "functions.php" e "index" se encuentran pegados en el mensaje anterior, así que agradecería que me indicaran dónde y cómo tengo que poner esta línea de código, y qué debo de poner en ambos archivos.

Sospecho que hay que editar igualmente el index, por la simple razón de que fue ahí donde cambié la secuencia de código para solucionar el problema con el "title", según el amigo Master, y hay una segunda secuencia de código que a buen seguro está en concordancia con la modificación que hay que hacerle al "functions.php".

Resumiendo:
¿Donde y cómo tengo que modificar el "function.php", e igualmente con el "index.php".

Un paso a paso si no es mucho pedir.

Con los tutoriales en inglés no tengo problema, pero es que no entendería qué demontres hacer aunque estuvieran en español.

Muchas gracias y perdón por mi gran ignorancia en la materia.

INFORMACIÓN ADICIONAL.
Este es el error de validación que me da ahora. Es sólo un error por línea y miniatura-entrada que genero. Antes me daba dos.

ERROR DEL VALIDADOR.
Cita:
# Error Line 162, Column 92: document type does not allow element "h3" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

…tle="Entrada 5"><h3 id="post-title-51">Entrada 5</h3><img src="" alt="Entrada …

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

ERROR DEL CÓDIGO FUENTE:
Cita:
161 <div id="the_post_thumbnail-51" class="thumbnail">

162 <a href="http://localhost/wp/?p=51" rel="bookmark" title="Entrada 5"><h3 id="post-title-51">Entrada 5</h3><img src="" alt="Entrada 5 " /></a>

163 <p><a href="http://localhost/wp/?category_name=sin-categoria" title="Ver todas las entradas en Sin categoría" rel="category">Sin categoría</a></p>
165 </div>

Última edición por tranzorx; 21/03/2011 a las 18:06
  #7 (permalink)  
Antiguo 21/03/2011, 18:21
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Errores de validación W3C en un Theme de WordPress

Que doctype estas utilizando ?, seguramente sea strict, por eso el mensaje, no podes tener un elemento de bloque dentro un inline osea no podes tener el h3 dentro del a, proba cambiar el orden, algo asi:

Código HTML:
Ver original
  1. <h3 id="post-title-51">
  2.     <a href="http://localhost/wp/?p=51" rel="bookmark" title="Entrada 5">
  3.     Entrada 5<img src="" alt="Entrada 5 " /></a>
  4. </h3>

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #8 (permalink)  
Antiguo 21/03/2011, 18:30
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Hola.
Probaré lo que me dices si sé encontrarlo en todos los archivos que entran en juego para formar el código fuente final.

Y no, el Doctype no es el estricto.

Cita:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Si quieres ver la tienda en el hosting está aquí, con un montón de errores.
  #9 (permalink)  
Antiguo 21/03/2011, 18:39
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Errores de validación W3C en un Theme de WordPress

Falla tambien en transitional, hace tanto que no maqueto que ya ni me acuerdo :), creo que esta en el fichero index.php y Archive.php
__________________
http://es.phptherightway.com/
thats us riders :)
  #10 (permalink)  
Antiguo 21/03/2011, 19:22
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Seguimos en las mismas.
Tengo nociones de todo un poco pero si no tengo instrucciones precisas no hay nada que hacer.
Llevo semanas haciendo pruebas, así que del método de ensayo y error estoy bastante quemado.

Bueno... al menos hemos resuelto la mitad del problema, que ya es bastante.
Pero me cabrea mucho tener una plantilla que me genere un error cada vez que abro una entrada nueva en las miniaturas del homepage.

Si la cuestión se pone muy cuesta arriba siempre puedo acudir a los programadores de la plantillas, que en realidad es responsabilidad de ellos el vender un producto debidamente terminado.

Lo mío es el SEO, y me repatea tener errores de código que penaliza el posicionamiento.
Y cuantos más productos haya en la tienda, más errores tendré.

Mañana más.

Un saludo a todos y muchas gracias por la ayuda.
  #11 (permalink)  
Antiguo 22/03/2011, 18:18
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Editar código que genera miniaturas en la entrada

Hola.
Alguien seria tan amable de darme unas indicaciones sobre cómo debo de editar el código php que controla la generación de las miniaturas que se generan con cada entrada/post de la plantilla.
Soy novato, por lo que necesito un paso a paso.
Desconozco la jerga propia de la profesión.


Si fuesen tan amables les quedaría muy agradecido.

Salud!!
  #12 (permalink)  
Antiguo 22/03/2011, 20:01
Avatar de pao01
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 1.875
Antigüedad: 15 años, 10 meses
Puntos: 351
Respuesta: Editar código que genera miniaturas en la entrada

tranzorx he movido tu tema ya que la consulta es diferente a la del hilo anterior.
__________________
Entre más estrecha la mente, más grande la boca.- Ted Cook
Autosconarte-Blog
  #13 (permalink)  
Antiguo 23/03/2011, 06:17
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 8 meses
Puntos: 638
Respuesta: Editar código que genera miniaturas en la entrada

Sería bueno que nos dieras algunas pistas... algo de código no vendría mal (con hielo ), sobre todo si encuentras una linea que diga the_post_tumbnail()

Saludos
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose
  #14 (permalink)  
Antiguo 23/03/2011, 10:37
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Editar código que genera miniaturas en la entrada

Cita:
pao01
Respuesta: Editar código que genera miniaturas en la entrada
tranzorx he movido tu tema ya que la consulta es diferente a la del hilo anterior
Pero... si es que me han partido el post por la mitad.
¿Cómo se les ocurre hacer eso con un problema que está todo relacionado hombre?
Ahora tengo que volver a poner todo de nuevo para que los usuarios puedan entender de dónde viene el problema.
__________________________________________________ ____

Bueno... el problema viene de que tengo una página clonada en localhost para ver si le quito unos errores que me da una plantilla "Ecommerce Theme" con la generación de las miniaturas en el homepage cada vez que hacía una entrada nueva.
Cada vez que hacía una de ellas se me producían dos errores y una advertencia en el validador W3C. En el post original está explicado con más rollo, pero esta es la base del problema.

EL PROBLEMA Y EL POST INICIAL VIENE DE AQUÍ.

Creo que el link es suficientemenente explícito, pero lo que he hecho hasta ahora es editar el archivo index.php según el amigo forefo "Master" que me dijo que cambiara lo siguiente:

Archivo index.php
Código PHP:
Ver original
  1. <!--include sidebar-->
  2.  
  3. <?php include(TEMPLATEPATH."/l_sidebar.php");?>
  4.  
  5. <div id="content">
  6.  
  7. <!--index.php-->
  8.  
  9. <?php if (have_posts()) : while (have_posts()) : the_post(); // the loop ?>
  10.  
  11. <div id="post-<?php the_ID(); ?>" class="thumbnail">
  12.  
  13. <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a>
  14.  
  15. <p><?php the_category(', ') ?></p>
  16. </div>
  17.  
  18. <?php endwhile; // end of one post ?>
  19.  
  20. <!-- Previous/Next page navigation -->
  21. <div class="page-nav">
  22. <div class="nav-previous"><?php previous_posts_link('&laquo; Previous Page') ?></div>
  23. <div class="nav-next"><?php next_posts_link('Next Page &raquo;') ?></div>
  24. </div>
  25.  
  26. <?php else : // do not delete ?>
  27.  
  28. <h3>Page Not Found</h3>
  29. <p>We're sorry, but the page you are looking for isn't here.</p>
  30. <p>Try searching for the page you are looking for or using the navigation in the header or sidebar</p>
  31.  
  32. <?php endif; // do not delete ?>

He cambiado el post-< de la línea 13 y lo he dejado así:

LINEA ORIGINAL
Cita:
13. <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a>
LINEA EDITADA
Cita:
13. <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-title-<?php the_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a>
Ahora va perfecto porque me genera justo la mitad de los errores.

La otra línea donde he visto que había otra secuencia igual a la anterior era la número 11.

Cita:
<div id="post-<?php the_ID(); ?>" class="thumbnail">
He probado todas estas opciones sin éxito:

Cita:
<div id="post-tumb-<?php the_ID(); ?>" class="thumbnail">
<div id="post-thumbnail-<?php the_ID(); ?>" class="thumbnail">
<div id="post-Thumbnail-<?php the_ID(); ?>" class="thumbnail">
<div id="the_post_thumbnail-<?php the_ID(); ?>" class="thumbnail">
Me he leído el artículo ESTE sobre "Function Reference/the post thumbnail", pero no entiendo nada puesto que no tengo ni idea sobre PHP y la estructura de archivos que sigue WordPress.

Espero que haya información suficiente como para que alguien versado en la materia me pueda echar un cable si es tan amable.
Se lo agradecería profundamente.

Muchas gracias.

Un saludo.

P.D.:
En el post original he pegado más arhivos PHP por si son necesarios.
  #15 (permalink)  
Antiguo 23/03/2011, 11:10
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 8 meses
Puntos: 638
Respuesta: Editar código que genera miniaturas en la entrada

Si te fijas, no estás usando the_post_thumbnail() en ningún lugar, lo que estás haciendo es poniendo un nombre a un id para que te identifique el post en cuestión, osea, estás modificando en html.

La linea 13 déjala hasta el cierre del h3:
Código PHP:
Ver original
  1. <h3 id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
y a continuación, en la linea 14 pones esto
Código PHP:
Ver original
  1. <?php
  2. if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  3.   the_post_thumbnail();
  4. }
  5. ?>
Y luego the_content()... Al final debe quedarte algo así:
Código PHP:
Ver original
  1. <h3 id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
  2. <?php
  3. if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  4.   the_post_thumbnail();
  5. }
  6. the_content();
  7. ?>

Fíjate que he cambiado en el título, la disposición de las etiquetas a y h3: antes era <a><h3>... </h3></a>, ahora es <h3><a>... </a></h3>, lo cual es solo cuestión de organizar bien tu código
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose
  #16 (permalink)  
Antiguo 23/03/2011, 12:03
Avatar de pao01
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 1.875
Antigüedad: 15 años, 10 meses
Puntos: 351
Respuesta: Errores de validación W3C en un Theme de WordPress

tranzorx mis disculpas, ya he vuelto a combinar ambos temas.

Nuevamente disculpas.
__________________
Entre más estrecha la mente, más grande la boca.- Ted Cook
Autosconarte-Blog
  #17 (permalink)  
Antiguo 23/03/2011, 12:26
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

YA HA VUELTO A PEGAR EL MODERADOR TODA EL HILO DE POST.
ASÍ PUEDES CONSULTAR MI PROBLEMA DESDE EL PRINCIPIO.
¡¡Muchas gracias señora moderadora!!


Hola.
No sé si he sido yo que no he sabido transcribir el código al index.php, pero se me han escogorciado todas las miniaturas y han desaparecido los estilos de CSS del body. Sólo me he quedado con el header, y ahora me sale una tabla con esta indicación:
Cita:
Fatal error: Call to undefined function has_post_thumbnail() in C:\wamp\www\wp\wp-content\themes\Ecommerce-Pink\index.php on line 19
Call Stack
# Time Memory Function Location
1 0.0006 671568 {main}( ) ..\index.php:0
2 0.0009 676432 require( 'C:\wamp\www\wp\wp-blog-header.php' ) ..\index.php:17
3 0.6775 47017352 require_once( 'C:\wamp\www\wp\wp-includes\template-loader.php' ) ..\wp-blog-header.php:16
4 0.6847 47089808 include( 'C:\wamp\www\wp\wp-content\themes\Ecommerce-Pink\index.php' ) ..\template-loader.php:43


Desde la mayor de las ignorancias: digo yo que no debería de haber un error tan gordo en una plantilla de pago.
Aquí la dirección de la plantilla:Ecommerce Theme


A continuación el nuevo index.php.
Las líneas que estaban mal las he comentado (en girs) y he añadido las nueva (en azul).
La línea 19 la he marcado en rojo.

Cita:
<?php get_header(); ?>

<!--include sidebar-->
<?php include(TEMPLATEPATH."/l_sidebar.php");?>

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

<?php if (have_posts()) : while (have_posts()) : the_post(); // the loop ?>

<!-- <div id="post-<?php the_ID(); ?>" class="thumbnail">
<a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-title-<?php the_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a> -->


<!-- PRINCIPIO CODIGO NUEVO -->

<h3 id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>

<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.

the_post_thumbnail();

}
the_content();
?>
<!-- FINAL CODIGO NUEVO -->


<p><?php the_category(', ') ?></p>
</div>



<?php endwhile; // end of one post ?>

<!-- Previous/Next page navigation -->
<div class="page-nav">
<div class="nav-previous"><?php previous_posts_link('&laquo; Previous Page') ?></div>
<div class="nav-next"><?php next_posts_link('Next Page &raquo;') ?></div>
</div>

<?php else : // do not delete ?>

<h3>Page Not Found</h3>
<p>We're sorry, but the page you are looking for isn't here.</p>
<p>Try searching for the page you are looking for or using the navigation in the header or sidebar</p>

<?php endif; // do not delete ?>


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

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

Última edición por tranzorx; 23/03/2011 a las 12:39
  #18 (permalink)  
Antiguo 25/03/2011, 03:12
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Por favor, no me dejéis así con la casa a medias.
Gracias.
  #19 (permalink)  
Antiguo 26/03/2011, 06:05
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Errores de validación W3C en un Theme de WordPress

tranzorx, deberias comprobar nuevamente la referencia que te dejo rogertm, al inicio dice y cito:

Cita:
Note: To enable post thumbnails, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file. See also Post Thumbnails.
Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #20 (permalink)  
Antiguo 26/03/2011, 11:35
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Voy a sonar pesado y reiterativo, pero no tengo ni idea de lo que quiere decir ese tutorial en inglés.
Entiendo perfectamente que hay que editar el index.pnp y el functions.php de la plantilla, pero... creo que dejé claro que no tengo NI IDEA de php, y por tanto si no se me dan instrucciones precisas, expresas y explícitas sobre quita esto de aquí y pon esto allá, no vamos a ninguna parte.

El problema no es que el tutorial esté en inglés, si estuviera en castellano tampoco lo entendería.

Dicho esto, si alguien quiere echarme una mano le quedaría muy agradecido.

Si alguna vez alguien visita el apartado de este foro dedicado al SEO, probablemente podré ayudarle.

Saludos.

"Todos somos ignorantes, lo que ocurre es que no todos ignoramos las mismas cosas".
  #21 (permalink)  
Antiguo 26/03/2011, 14:49
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Errores de validación W3C en un Theme de WordPress

En teoria en el functions.php deberías agregar esto:
Código PHP:
Ver original
  1. if ( function_exists( 'add_theme_support' ) ) {
  2.   add_theme_support( 'post-thumbnails' );
  3. }
__________________
http://es.phptherightway.com/
thats us riders :)
  #22 (permalink)  
Antiguo 27/03/2011, 07:23
Avatar de tranzorx  
Fecha de Ingreso: marzo-2008
Mensajes: 114
Antigüedad: 16 años, 1 mes
Puntos: 7
Respuesta: Errores de validación W3C en un Theme de WordPress

Pues no, no ha funcionado. Ni para bien ni para mal.

Pero dejémoslo ya aquí. Me da vergüenza ajena seguir con el tema.

Un saludo.

Etiquetas: php, validar, themes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:04.