Offset for Loop

It’s a php error probably because its expecting either one of your if statements to be closed before the endwhile. It’s hard to tell without seeing all the code but at a guess check this one is closed: if ($tags) { also I would wrap your foreach in curly brackets. Maybe just preference though… foreach($tags … Read more

Category sticky latest

What you’re looking for is best achieved using a custom query: $top = new WP_Query( array( ‘category’ => ‘YOUR_CATEGORY_SLUG’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1 ) ); if( $top->have_posts() ) { $top->the_post(); // Do things as if we were in the loop… } By default, sticky posts are brought to the top … Read more

How to create multiple loop in archive page?

I would avoid this kind of excess indentation at all costs, however this should work although I haven’t tested it. Please let me know if there are syntax errors so that I can correct them. <!– first loop : 1 post –> <?php if ( have_posts() ): the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/31361/<?php the_permalink() ?>” rel=”bookmark” title=”” … Read more

WP Query get only 1 post (sticky, not sticky etc)

Why don’t you use a fat-free $wpdb->get_var() for the task? global $wpdb; $ID = $wpdb->get_var(“SELECT `ID` FROM {$wpdb->posts} WHERE `post_type`=’post’ AND `post_status`=’publish’ ORDER BY `post_date_gmt` DESC LIMIT 1;”); $post = $ID ? get_post($ID) : null; // Now get the actual post This is way more efficient and light-weight. Without all the bells and whistles of … Read more

use custom field value as post category in loop

Nevermind. Got it working with: <?php global $wp_query; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $store_name = (get_post_meta($post->ID, ‘store_name’, true)); query_posts(array(‘posts_per_page’ => ’10’,’paged’=>$paged,’category_name’=>$store_name)); ?>

Add 2 values to post__not_in

This should display 5 posts per page (-1 for all of them on one page), with the post ID’s $value1 and $value2 being ignored. Ensure $value1 and $value2 are integers. $args = array( ‘numberposts’ => 5, ‘posts_per_page’ => get_option(‘posts_per_page’), ‘paged’ => $paged, ‘post__not_in’ => array( $value1, $value2 ) ); query_posts($args); EDIT – With the further … Read more