get_the_ID not returning correct ID value
The array intialize of the variable $valid_post_id is incorrect. Change: <?$valid_post_id(‘1′,’2′,’3′,’4’);?> to <?php $valid_post_id = array(‘1′,’2′,’3′,’4’);?>
The array intialize of the variable $valid_post_id is incorrect. Change: <?$valid_post_id(‘1′,’2′,’3′,’4’);?> to <?php $valid_post_id = array(‘1′,’2′,’3′,’4’);?>
You are overwriting the query that loads with the page (which you saved to $temp) – why not just use the one that loads with the page: while(have_posts()) : the_post(); // put the post here endwhile;
When you initiate a Loop, split it up like so: <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <!– do stuff … –> <?php endwhile; ?> <?php endif; ?> Anything inside the if statement but outside the while statement will run if have_posts is true, but will not be Looped for each … Read more
get_the_author_meta accepts two parameters $field – Field name for the data item to be returned. $userID – If a user ID is passed to the function, it will return data for the specified user ID. So just pass the user ID or author ID eg: if (get_the_author_meta(‘aim’,$author_id)) { …
a) Try to initialize the $count variable before your loop: $counts=0; $loop = new WP_Query( array( ‘post_type’ => ‘focus-areas’, ‘posts_per_page’ => -1 ) ); while ( $loop->have_posts() ) : $loop->the_post(); $counts++; echo $counts; echo ” – “; endwhile; b) or use the current_post method (starts at 0) of WP_Query: $loop = new WP_Query( array( ‘post_type’ … Read more
get_query_var will get the category from the main query, and it is only going to be set for some pages, such as category archives. It is not set for “single” pages or tag archives or a many other kids of “pages”. The value that get_query_var returns is something like a ‘search’ variable. It will be … Read more
You can do that with get_comments. <?php $comments = get_comments(array( ‘number’ => 10, // 10 comments ‘status’ => ‘approve’, // only approved comments ‘post_status’ => ‘publish’, // only on published posts )); // do stuff with $comments You can see how the core itself does this in the recent comments widget.
Get all of your posts in one query, then count the iterations of your loop. Pseudo-code follows. if ( $query->have_posts() ) { $i = 0; while ( $query->have_posts() ) { // If $i is 5 (5th post), end one row and start the next if (++$i == 5) { echo ‘</tr><tr>’; } // the rest … Read more
Problem is here: <div id=”my-video” style=”display:none;”> as you can see, id is static and is the same for all posts. First of all this is not compliant with html standard: tag id must be unique. As a side effect if you use the id selector in jquery and the id is used a lot of … Read more
Regarding the use of query_posts, as @epilektric said never use it. Use WP_Query instead. Another consideration is to keep your code DRY. What I suggest you is: Run the loop one time, and put the posts in a helper array, using 2 keys one for even one for odd. Cycle that array and output the … Read more