Revision: 46429
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 19, 2011 04:06 by serialk89
Initial Code
<div class="overview"> <div class="contenido"> <?php $ppp = 3; $pag = $_GET['pag']; if($pag == "" || $pag == 1){ $offset = 0; $pag = 1; } else { $offset = ($pag-1)*$ppp; } $my_query = new WP_Query(array('category_name' => 'blog', 'posts_per_page' => $ppp, 'offset' => $offset)); while ($my_query->have_posts()) : $my_query->the_post(); $excerpt = get_the_excerpt(); add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 145, 100, true ); // Normal post thumbnails add_image_size( 'single-post-thumbnail', 400, 9999 ); // Permalink thumbnail size ?> <div class="homepost"> <div class="thumb_a"> <a title="<?php the_title(); ?>" rel="bookmark" href="<?php the_permalink(); ?>"> <?php if(has_post_thumbnail()) { the_post_thumbnail(array(145,100)); } else { echo '<img src="'.get_bloginfo("template_url").'/images/img-default.jpg" width="150" height="64" />'; } ?> </a> </div> <div class="rightcontp"> <div class="bubble"><a title="Comentarios en <?php the_title(); ?>" class=" " href="<?php the_permalink(); ?>/#respond"><?php comments_number('0','1','+'); ?></a></div> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <p><?php echo string_limit_words($excerpt,80);?> <?php //echo "<br />"; //echo "<a href='" . get_permalink() . "'#more-$post->id\" class='linkseguirleyendo'><img src='".get_template_directory_uri()."/images/btonleermas.png' width='31' height='33' />Sigue Leyendo</a>"; ?></p> <div class="post-meta">Publicado por <a href="<?php the_author_link(); ?>"><?php the_author_link(); ?></a> en <?php the_time('m/j/y g:i A') ?></div> </div> </div> <?php endwhile; ?> </div> </div> </div> <div class="paginacion_pos"> <?php //OBTENGO LA CANTIDAD DE POST $p=0; $my_query = new WP_Query('category_name=blog&posts_per_page=100'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php $p++; ?> <?php endwhile; ?> <?php //GENERANDO PAGINACION //cantidad de paginas $x = $p / $ppp; if( $x > 1) { if ( $pag > 1 ) { echo "<span><a href='?pag=".($pag-1)."'>Anterior</a></span>-"; } for ( $k = 1; $k < $x; $k++ ) { if( $k == $pag ) { echo $k; } else { echo "<span><a href='?pag=".$k."'>".$k."</a></span>-"; } } if( $pag < $x ) { echo "<span><a href='?pag=".($pag+1)."'>Siguiente</a></span>-"; } } ?> </div>
Initial URL
Initial Description
Este código pagina los resultados de wordpress, según los parámetros que se le asignen a la clase WP_query.
Initial Title
PAGINACION DE POST WORDPRESS
Initial Tags
post, wordpress
Initial Language
PHP