Get Posts updated or published within the last x hours

here is a shorter version that assumes the GET parameter ?time=[integer] (for example ?time=8) add_filter(‘posts_where’, ‘filter_where’, 11); function filter_where($where=””) { if(isset($_GET[‘time’])){ $time = $_GET[‘time’]; $time=(int)$time; // only allow integers if(in_array($time,array(8,24,72))){ $where .= ” AND post_date > ‘”.date(‘Y-m-d H:i:s’, strtotime(‘-“.$time.” hours’)).”‘”; } } return $where; }

query_posts() vs get_posts() multiple loops [duplicate]

Thanks to tips given by the commentators I was able to achieve this 🙂 <?php if ( is_front_age() ){ $most_viewed_posts = new WP_Query( array(‘v_sortby’ => ‘views’, ‘v_orderby’ => ‘DESC’, ‘showposts’ => 10, ‘cat’=> 3) ); } while ( $most_viewed_posts->have_posts() ) : $most_viewed_posts->the_post(); ?> //post structure <?php wp_reset_postdata(); ?>

Change order of posts

Your question is not very detailed. It is hard to work out exactly what you are doing but I am assuming that you are trying to sort posts by a custom meta meta_key/meta_value. This the formula for that (annotated but basically lifted from the Codex): $args = array( ‘post_type’ => ‘your_post_type’, // I don’t know … Read more

Multi row post list

Ended up with using this code: <?php query_posts(‘category_name=Menucard’); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class=”span4 post move pull-left”> <?php //echo post here the_content(); ?> </div> <!– close .post div –> <?php $counter++; if ($counter % 3 == 0) { echo ‘<div style=”clear:both;”></div>’; } ?>

Custom post type archive page for multiple post types

From WordPress Codex: Function Reference/post type archive title This is optimized for archive.php and archive-{posttype}.php template files for displaying the title of the post type. “Title of post type” is the label, not the post type registered name. You can get the registered post type name using get_queried_object(); like this: <?php $obj = get_queried_object(); $post_type … Read more

Passing a varible from jQuery to PHP

First, don’t use query_posts. Second… I think this can be done with AJAX but is there a more simple method and give me a clean URL? PHP runs on the server. Items are “clicked” on the client machine. The only way to pass that “clicked” value back to PHP is via AJAX. Within a WordPress … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)