Ver Mensaje Individual
  #7 (permalink)  
Antiguo 02/07/2014, 14:20
Avatar de paxarin
paxarin
 
Fecha de Ingreso: enero-2010
Ubicación: Santander
Mensajes: 413
Antigüedad: 14 años, 2 meses
Puntos: 6
Respuesta: Mostrar las publicaciones de un wordpress en una página web

Por si a alguien le pueda interesar consegui hacer que funcionara con un poco de ayuda de todos.
Este es el php que hace que se muestren todos los post con su titulo
Código PHP:
Ver original
  1. <?php
  2.     include 'wordpress/wp-load.php';
  3.     //$args=array('cat'=>0);
  4.     //$category_posts = new WP_Query($args);
  5.      $category_posts = new WP_Query('posts_per_page=4');
  6.     if( $category_posts->have_posts() ):
  7.         while( $category_posts->have_posts() ): the_post();
  8.             $category_posts->the_post();
  9.     ?>
  10.             <h3><?php the_title() ?></h3>
  11.             <p><?php echo substr(strip_tags($post->post_content), 0, 120);?></p>
  12.  
  13.     <?php
  14.         endwhile;
  15.         wp_reset_postdata();
  16.     else:
  17.     ?>
  18.         <p>No hay entradas</p>
  19.     <?php endif; ?>
Ahora esta limitado a que me muestre solo 4 post y solo 120 caracteres,si se cambia mostrara más.
Y si cambiamos estas lineas comentadas
//$args=array('cat'=>0);
//$category_posts = new WP_Query($args);
por esta
$category_posts = new WP_Query('posts_per_page=4');
Para quitar el limite de caracteres hay que cambiar esta linea
<p><?php echo substr(strip_tags($post->post_content), 0, 120);?></p>
por esta otra
<p><?php the_content() ?>
Mostrara todos los post y todo su contenido.
Quien sabe si esto le pueda valer a alguien más.
__________________
http://www.paxarindesign.es

Última edición por paxarin; 02/07/2014 a las 14:22 Razón: Olvido de una linea de php