Title: Check my code, please?
Last modified: August 18, 2016

---

# Check my code, please?

 *  [ssorcdivad](https://wordpress.org/support/users/forefront/)
 * (@forefront)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/)
 * Hi,
 * I (no programmer!) am doing my first WP site and wondered if someone could check
   the code of these three templates for any obvious mistakes.
 * The site is more of a “traditional” website managed with WP than a blogging site,
   as such.
 * 1: index.php – used in conjunction with a plugin to make a single post my home
   page.
 * `<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?> <h2
   ><?php the_title(); ?></h2> <?php the_content(''); ?> <?php endwhile; ?> <?php
   else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you 
   are looking for something that isn't here.</p> <?php endif; ?>
 * 2: category.php – prints a list of articles within the current category:
 * `<h2><?php single_cat_title(); ?></h2>
    <p> <?php echo(category_description(the_category_ID(
   false))); ?> </p> <ul> <?php if ($posts) : foreach ($posts as $post) : start_wp();?
   > <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php 
   the_title(); ?></a><br/> <?php the_excerpt(); ?> </li> <?php endforeach; else:?
   > <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?
   ></ul>
 * 3: single.php – when someone clicks on any post this is the template:
 * `<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h2><?php the_title();?
   ></h2> <?php the_content(); ?> <?php endwhile; else: ?> <p>Sorry, no posts matched
   your criteria.</p> <?php endif; ?>
 * Thank you!

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

 *  Thread Starter [ssorcdivad](https://wordpress.org/support/users/forefront/)
 * (@forefront)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326100)
 * Is there a better way for me to display the code for this?
 *  Thread Starter [ssorcdivad](https://wordpress.org/support/users/forefront/)
 * (@forefront)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326270)
 * Hi,
 * I am new here and this is my first set of simple templates using WordPress. Am
   I posting this in the wrong place to get a response?
 * Thank you.
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326271)
 * You’re posting parts of the Existing WordPress Files, and what you like to do
   them?
 * spencerp
 *  [spirit892](https://wordpress.org/support/users/spirit892/)
 * (@spirit892)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326272)
 * I’m a little confused. Is there a problem with the code, or would you like a 
   review of your site?
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326273)
 * spirit, I think they want to be able to print some stuff via catagory..I just
   went through again:
    “2: category.php – prints a list of articles within the 
   current category:”
 * Which I’m not sure about, because GamerZ plugin does if for each post, I’m not
   sure about full “PAGES” worth of content. Or even just the content that you want
   printed from the Catagories..I never did that before. But GamerZ could help then,
   when he gets online…
 * For this: “1: index.php – used in conjunction with a plugin to make a single 
   post my home page.”
    You’d almost want a sticky plugin, which makes your homepage
   post, in all pages…or just add a <div> section to the header.php …..like I did
   here:
 * [http://www.vindictivebastard.net/test101/](http://www.vindictivebastard.net/test101/)
 * As for number three, there is and should be a template ready to go for each page…
 * spencerp
 *  Thread Starter [ssorcdivad](https://wordpress.org/support/users/forefront/)
 * (@forefront)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326339)
 * >>>I’m a little confused. Is there a problem with the code, or would you like
   a review of your site?
 * Hi,
 * I created three templates (above) and wanted someone to review the code for correctness
   and advise any changes/improvements.
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326340)
 * What you posted above – are NOT templates, just snippets of code. Take a working
   theme and see how a complete template file is done.
 * Do not post long code here – use [http://pastebin.com](http://pastebin.com) or
   a similar service.
 *  Thread Starter [ssorcdivad](https://wordpress.org/support/users/forefront/)
 * (@forefront)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326342)
 * I took a working them and edited it then I took the code I wanted checked from
   the templates I created and pasted that, trying to avoid posting long code.
 * If anyone can actually say whether the PHP code in these three code samples look
   correct, with loops in the correct place, I’d be grateful.

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

The topic ‘Check my code, please?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 4 participants
 * Last reply from: [ssorcdivad](https://wordpress.org/support/users/forefront/)
 * Last activity: [20 years, 3 months ago](https://wordpress.org/support/topic/check-my-code-please-2/#post-326342)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
