Stuck in the query loop

<div class=”pr_grid_cell clearfix”> <?php //for each category, show posts $categories=get_categories(); foreach($categories as $cat) { $args=array( ‘post_type’ => ‘products’, ‘showposts’ => -1, ‘category__in’ => array($cat->term_id) ); $posts = new wp_query($args); // This is the best way to if ($posts->have_posts()) while ($posts->have_posts()) { //condional if/while 2-in-1. If you dont check have_posts, you’ll get an ugly error when … Read more

Query posts by last comments

i thinks this help to you $args = array ( ‘status’ => ‘approve’, ‘number’ => ‘5’ ); $comments = get_comments( $args ); if ( !empty( $comments ) ) : echo ‘<ul>’; foreach( $comments as $comment ) : echo ‘<li><a href=”‘ . get_permalink( $comment->comment_post_ID ) . ‘#comment-‘ . $comment->comment_ID . ‘”>’ . $comment->comment_author . ‘ on … Read more

How to store and receive variables in WP sessions?

Sessions aren’t enabled in wordpress by default, if you want to activate php sessions add this at the beginning of your functions.php: if (!session_id()) { session_start(); } You now can use $_SESSION[‘your-var’] = ‘your-value’; to set a session variable. Take a look at the PHP documentation on sessions. Update: There was a second answer, which, … Read more