• 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. 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)
  • 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++
    https://notepad-plus.sourceforge.net/uk/about.php

    which highlights code for you.

    Thread Starter adapting

    (@adapting)

    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

    (@adapting)

    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.