Title: Need direction on customizing code
Last modified: August 19, 2016

---

# Need direction on customizing code

 *  Resolved [Diventare Creative](https://wordpress.org/support/users/wms-group/)
 * (@wms-group)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/)
 * I have a blog feeding into a custom template using this code in the body:
 *     ```
       <?php while (have_posts()): the_post(); ?>
       <?php endwhile; ?>
       ```
   
 * What would I have to add for it to read only one post from one specific blog?
 * Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081795)
 * Use the [template tag](http://codex.wordpress.org/Template_Tags), [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts),
   and the **p=x** argument.
 *  [iridiax](https://wordpress.org/support/users/iridiax/)
 * (@iridiax)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081796)
 * This is [the Loop](http://codex.wordpress.org/The_Loop). To customize, see:
 * [http://codex.wordpress.org/Template_Tags/query_posts](http://codex.wordpress.org/Template_Tags/query_posts)
 *  Thread Starter [Diventare Creative](https://wordpress.org/support/users/wms-group/)
 * (@wms-group)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081797)
 * Thanks Michael,
 * Not sure I am familiar enough to figure that out myself, are there any examples?
 *  Thread Starter [Diventare Creative](https://wordpress.org/support/users/wms-group/)
 * (@wms-group)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081798)
 * I think what I need to do is insert this snippet between my existing code to 
   call from one category?
 * So:
 *     ```
       <?php while (have_posts()): the_post(); ?>
       <?php endwhile; ?>
       ```
   
 * would become
 *     ```
       <?php while (have_posts()): the_post(); ?>
       <?query_posts('cat=-3'); ?>
       <?php endwhile; ?>
       ```
   
 * With the number 3 being replaced with my category name. Is this right?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081803)
 * It would be more like:
    <?query_posts(‘cat=-3’); ?>
 * <?php while (have_posts()): the_post(); ?>
 *  Thread Starter [Diventare Creative](https://wordpress.org/support/users/wms-group/)
 * (@wms-group)
 * [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081805)
 * Thanks everyone, read the articles and used your code examples to accomplish 
   what I needed!
 * Here’s what my final code looks like:
 *     ```
       <div id="rightcol2">
           <p><img src="../images/tipsheader.gif" width="204" height="37"></p>
           <div class="item">
             <?php if (have_posts()) : ?>
             <?php $temp_query = $wp_query; ?>
             <?php query_posts('category_name=tips&amp;showposts=1'); ?>
             <?php while (have_posts()) : the_post(); ?>
             <small>
             <?php the_time('F jS, Y') ?>
             <!-- by <?php the_author() ?> -->
             </small>
             <div class="entry">
               <?php the_content('Read the rest of this entry &raquo;'); ?>
             </div>
           </div>
           <?php endwhile; ?>
           <?php else : ?>
           <?php endif; ?>
         </div>
       ```
   
 * It shows one post from the category “tips”. Awesome!!!
 * Just in case anyone cares, my head code reads like this:
 *     ```
       <?php define('WP_USE_THEMES', false); get_header(); ?>
       require('../wordpress/wp-blog-header.php');
       query_posts('showposts=1');
       ?>
       ```
   
 * Thanks everyone!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Need direction on customizing code’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [customization](https://wordpress.org/support/topic-tag/customization/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [Diventare Creative](https://wordpress.org/support/users/wms-group/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/need-direction-on-customizing-code/#post-1081805)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
