• Hi.

    I am trying to paginate a large list but receive the following error:

    Parse error: syntax error, unexpected $end in /usr/local/apache/htdocs/html/lcm_dev/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 7

    This is the code that I am using:

    <ul>
    <?php $i=0; $recent = new WP_Query("cat=13&showposts=-1"); while($recent->have_posts()) : $recent->the_post();?>
    <?php $i++;?>
    
    <li><div class="latest_icon"><?php get_cat_icon('priority="true"');?></div><div class="latest_info"><b><a><?php the_title(); ?></a></b><?php swift_list_cats(2); ?><?php the_modified_date(); ?></div></li>
    <?php if( $i%5==0): ?><!--nextpage--><?php endif; ?>
    <?php endwhile; ?>
    </ul>

    Any ideas?
    Many Thanks

Viewing 15 replies - 16 through 30 (of 43 total)
  • So a single post which is called by the code contains the long list? wouldn’t you insert the nextpage into that post?, rather than the post or page which queries it?

    I’ve messed with trying to get queryposts to limit the number of posts per page before, so far that code I posted above isn’t doing it.
    However such a solution would apply to you only if the code was calling multiple posts which constitute your list. But it looks like that’s not whats going on.

    Thread Starter rivkasa

    (@rivkasa)

    The post is a list of titles of posts in certain categories – I want each 5 or so to be on a separate page

    conveiniently, I finally made query posts per page with pagnation work!
    It would seem you could find a solution doing it this way, but you’d need a custom page template, or make it conditional by page or category in your regular page template. I understand it won’t work in a post template, but I haven’t tried it.

    it will pull posts as titles from category 13 and limit their number per page as set in your reading settings, and show pagination.

    <?php
    
    query_posts ( array( 'cat' => 13, 'paged' => get_query_var('paged') ) );?>
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <h4 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', '' ) ?> <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a></h4>
    
    <?php endwhile; ?>
    
    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', '' ) ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', '' ) ); ?></div>
    
    <?php endif; ?>
    <?php wp_reset_query();?>

    here’s a basic demo, showing 2 post tiltes per page (as set in reading) from one category.
    demo

    Thread Starter rivkasa

    (@rivkasa)

    Looks good! I will try it a bit later. Thanks so much ??

    here’a a better query, let’s you set the number of posts independent of the wp reading settings, as well as include multiple categories:

    <?php
    
    query_posts( array(      'posts_per_page' => 2,      'cat' => '13', '14',    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ), ));?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    [...]
    <?php wp_reset_query();?>

    actually it can’t show multiple categories that way, so just omit one. Otherwise it’s good on setting the number of posts per page.
    I guess maybe it needs to also use this somehow:

    <?php query_posts('category__and=3&category__and=16&showposts='.get_option('posts_per_page')); ?>

    but adjusted for the specific number of posts per page as well.

    You can bet I’ll be working on trying to integrate all that, but I’m really weak with syntax. Perhaps someone will assist in the mean time.

    Thread Starter rivkasa

    (@rivkasa)

    Would it automatically show sub categories of a specific category?

    Try:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'category__in' => array( 3, 16 ),
    	'paged' => $paged
    );
    query_posts($args);
    ?>

    thanks esmi, I did, can’t figure out how to make it part of the query, and with keeping the posts per page. Not sure how to use it but I’ll keep hacking.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'category__in' => array( 3, 16 ),
    	'posts_per_page' => 1,
    	'paged' => $paged
    );
    query_posts($args);
    ?>
    Thread Starter rivkasa

    (@rivkasa)

    Hi esmi.

    Thanks for helping out. I used your code but didn’t get any pagination. My list has morphed into a blob that I can’t break up for some reason.

    thanks again, I tried a few things, I put

    <?php
    
    query_posts( );?>

    in front of your code, it works, posts from 2 categories, pagination shows up -but it doesn’t change pages when clicked.

    So I either have specified pagination independent of reading settings, or multiple categories. Not both. not yet..

    What exactly is it that you are trying to do? And are you trying to modify the main Loop query or create a secondary Loop?

    Thread Starter rivkasa

    (@rivkasa)

    I’m trying to create a secondary loop which is a list of titles from several categories. This works, but I cannot paginate it.

    Ah! To the best of my knowledge, you can’t paginate a secondary Loop’s output independently from the main Loop.

Viewing 15 replies - 16 through 30 (of 43 total)
  • The topic ‘crashing site when used within loop displaying a list’ is closed to new replies.