Listing all term items alphabetically / sorting loop
Listing all term items alphabetically / sorting loop
Listing all term items alphabetically / sorting loop
How to increase load time of an archive/search page (WP_Query)
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; }
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(); ?>
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
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>’; } ?>
Firstly you’d be better off creating a template file for your specific post type by creating a file called single-newsletter.php. WordPress will pick it up and use it automatically. Secondly add this function to your functions.php and call it to work out if it’s the most recent one: function is_latest_newsletter( $post_id = 0 ) { … Read more
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
BBPress Search results in WordPress search
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