Title: Custom Loop Errors
Last modified: August 18, 2016

---

# Custom Loop Errors

 *  [adapting](https://wordpress.org/support/users/adapting/)
 * (@adapting)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/custom-loop-errors/)
 * Hello
    I want to be able to list a specified number of posts in a specific category
   on my index page. I have been able to do this for some time using the below code:`
   <?php query_posts('cat=4&showposts=4'); ?> <?php while (have_posts()) : the_post();?
   >
 * <li id="post-<?php the_ID(); ?>">
    <h2> <a>" rel="bookmark" title='Permanent 
   Link to "<?php strip_tags(the_title()); ?>"'><?php the_title(); ?></a></h2>
 * <small>
    <?php comments_popup_link('<strong>0 <em>Comments</em></strong>', '<
   strong>No <em>Comments</em></strong>', '<strong>% <em>Comments</em></strong>','
   commentslink', '<span class="commentslink">Closed</span>'); ?> </small> | <small
   > By <?php the_author(',') ?> in <?php the_category(', ') ?> </small> | <small
   > <?php if (function_exists('time_since')) { echo time_since(abs(strtotime($post-
   >post_date_gmt . " GMT")), time()) . " ago"; } else { the_time('F jS, Y'); } ?
   > </small>
 *  <?php link_pages('<strong>Pages:</strong> ', '', 'number'); ?>
 * <!--
    <?php trackback_rdf(); ?> -->
 * <div style="height: .25em; clear: both;"></div>
 * I rendered the posts from the category using the above code in a custom loop 
   using the following include link in my Main index file;
    ` <?php include (TEMPLATEPATH.'/
   theloop-news.php'); ?>
 * But for some reason overnight this has stopped working. On all of my WP sites
   using this technique. And I have asked my host and he says nothing has changed
   overnight and other WP installs are working normally on the same server.
 * I am getting errors like:
    ` Parse error: syntax error, unexpected $end in /home/
   futcha/public_html/wp-content/themes/k2/theloop_casts.php on line 33
 * I am getting errors on [Futcha Records](http://www.futcha-records.com). The website
   is currently offline. If it needs to be online for you to think of a solution
   I can put it back online. Although I dont think making website online is that
   important to this request as I just need a new way to query posts within categories
   in my custom loops on my Main index page.

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

 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/custom-loop-errors/#post-407831)
 * Basically, that’s telling you the file ended abrubtly. Check that things like
   if…else statements are all closed up, and strings are properly put in “quotes”,
   that kind of thing.
 * It will help you to get an editor like notepad++
    [http://notepad-plus.sourceforge.net/uk/about.php](http://notepad-plus.sourceforge.net/uk/about.php)
 * which highlights code for you.
 *  Thread Starter [adapting](https://wordpress.org/support/users/adapting/)
 * (@adapting)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/custom-loop-errors/#post-407838)
 * Hi Maerk
    Thanks for the reply. I downloaded and installed the program.
 * The code I am currently using in a custom loop is:
    ` <?php query_posts('cat=
   4&showposts=4'); ?> <?php while (have_posts()): the_post(); ?>
 * <h2 id="post-<?php the_ID(); ?>">
    " rel="bookmark" title='Permanent Link to "
   <?php strip_tags(the_title()); ?>"'><?php the_title(); ?>
   </h2>
 * <small>
    <?php comments_popup_link('**0 _Comments_**', '**No _Comments_**', '**%
   _Comments_**', 'commentslink', '<span class="commentslink">Closed</span>'); ?
   > </small> | <small> By <?php the_author(',') ?> in <?php the_category(', ') ?
   > </small> | <small> <?php if (function_exists('time_since')) { echo time_since(
   abs(strtotime($post->post_date_gmt . " GMT")), time()) . " ago"; } else { the_time('
   F jS, Y'); } ?> </small>
 * <?php link_pages('**Pages:** ', '', 'number'); ?>
 * <!--
    <?php trackback_rdf(); ?> -->
 * This is producing the error:
    ` Parse error: syntax error, unexpected $end in/
   home/futcha/public_html/wp-content/themes/k2/theloop_casts.php on line 27  My
   knowledge of PHP is not great its pretty rubbish. But from looking at the above
   loop code I see no problem with quotes etc. Have you any ideas how I could change
   my PHP code?
 *  Thread Starter [adapting](https://wordpress.org/support/users/adapting/)
 * (@adapting)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/custom-loop-errors/#post-407862)
 * Managed to fix my multiple loops. For some reason things were not working with
   my previous query so I decided to work with the default loop from K2 using the
   following query at the top of each custom category loop:
    ` <?php query_posts('
   category_name=Podcasts'); ?>

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

The topic ‘Custom Loop Errors’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [loops](https://wordpress.org/support/topic-tag/loops/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [adapting](https://wordpress.org/support/users/adapting/)
 * Last activity: [19 years, 11 months ago](https://wordpress.org/support/topic/custom-loop-errors/#post-407862)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
