Several blog rolls on a single WordPress site using categories

Here’s a simple code example of how you can have separate blog roll areas on your WordPress website which show different types of blog content. Just add this query to your template file:

<?php
  $query = new WP_Query(array('category_name' => 'reviews'));
  
  if ($query->have_posts()): while ($query->have_posts()): $query->the_post();
?>

<div class="review">
  <h1><?php the_title(); ?></h1>
  <?php the_content(); ?>
</div>

<?php
  endwhile;
  else:
    echo 'No posts';
  endif;
?>

If you don’t want to hard code the blog roll in a template file, another option would be to add the category rolls to your menu in the menu editor. That way clicking on such a menu link will take you to the blog post list (archive) of the posts that belong to that archive.

Increment integer value in a database field using WPDB

Sometimes you need to update values incrementally in your WordPress database. You might for example have an upvote feature to which you automatically add points in an incremental fashion.

It was surprisingly hard to find examples of how to do this using Wpdb. But here’s an example of doing just that:

/* Have to use wpdb->query instead of wpdb->update because the latter assumes strings  */
  $results = $wpdb->query($wpdb->prepare("UPDATE foodsenglish SET popularity = popularity + 1 WHERE dbID = %d", $foodIdToSendThePointFor), ARRAY_A);