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

[SOLUCIONADO] filtro para fechas no funciona

Estas en el tema de filtro para fechas no funciona en el foro de WordPress en Foros del Web. Estoy usando este código que se supone debe de sacarme un loop con los posts subidos en las últimas 36 horas, pero no está funcionando ...
  #1 (permalink)  
Antiguo 21/01/2013, 10:08
 
Fecha de Ingreso: diciembre-2008
Mensajes: 738
Antigüedad: 15 años, 4 meses
Puntos: 15
filtro para fechas no funciona

Estoy usando este código que se supone debe de sacarme un loop con los posts subidos en las últimas 36 horas, pero no está funcionando porque me muestra todos los loops y no los que yo quiero:

El loop lo hice en base al codex de WP: http://codex.wordpress.org/Function_...ime_Parameters

Código PHP:
Ver original
  1. <?php
  2.                             function filter_where($where = '') {
  3.                             //posts in the last 24 Hours
  4.                             $where .= " AND post_date > '" . date('Y-m-d H:i:s', strtotime('-36 hours')) . "'";
  5.                             return $where;
  6.                           }
  7.                             add_filter('posts_where', 'filter_where');
  8.                             $query = new WP_Query("cat=".$categoria."");
  9.                         ?>
  10.                         <?php if(have_posts()) : ?><?php while($events_query->have_posts()) : $postnum = $postnum + 1; $events_query->the_post(); ?>
  11.                         <h1 class="negrocentro"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
  12.                         <?php endwhile; ?>
  13.                         <?php endif; ?>
  14.                         <?php
  15.                             remove_filter( 'posts_where', 'filter_where' );
  16.                         ?>
  #2 (permalink)  
Antiguo 21/01/2013, 10:23
 
Fecha de Ingreso: diciembre-2008
Mensajes: 738
Antigüedad: 15 años, 4 meses
Puntos: 15
Respuesta: filtro para fechas no funciona

Ya lo corregí

Código PHP:
Ver original
  1. <?php
  2.                             function filter_where($where = '') {
  3.                             //posts in the last 24 Hours
  4.                             $where .= " AND post_date > '" . date('Y-m-d H:i:s', strtotime('-36 hours')) . "'";
  5.                             return $where;
  6.                           }
  7.                             add_filter('posts_where', 'filter_where');
  8.                             $query = new WP_Query("cat=".$categoria."");
  9.                         ?>
  10.                         <?php if(have_posts()) : ?><?php while($query->have_posts()) : $query->the_post(); ?>
  11.                         <h1 class="negrocentro"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
  12.                         <?php endwhile; ?>
  13.                         <?php endif; ?>
  14.                         <?php
  15.                             remove_filter( 'posts_where', 'filter_where' );
  16.                         ?>

Etiquetas: php, post
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 03:34.