WordPress.org

Support

Support » Plugins and Hacks » PHPExec Categories – Multipage?

PHPExec Categories – Multipage?

  • I’m hoping someone can help me out. I don’t know much PHP so I think I just can’t get the code right. My site deviantknowledge.com is using Exec-PHP to make the Cateogry links (pages) pull dynamically. It works great execpt it only pulls 10 posts for each category. I would like it to put the 10 posts on the page and then have the “Next Page” option for more results. Can I do this? Is there another plugin I could use?

    Any help is very much appreciated. I searched on this for a long time and wrote a bunch of shotty loops and PHP code and just can’t seem to get it. Here’s the code I am using right now. Thanks anyone!

    <?php $recentPosts = new WP_Query();
    $recentPosts->query('cat=12');
    while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    
    <h3 class="h1" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <div class="auth"><span>Posted by <strong><?php the_author_posts_link(); ?></strong></span> on <?php the_time('F j, Y'); ?></div>
    <?php global $more; $more = 0; ?>
    <?php the_content('Read the rest of this story &raquo;'); ?>
    <!--Post Meta-->
    
    <div class="post-bottom">
    	<!--<?php if (function_exists('the_tags')) { ?><strong>Tags: </strong><?php the_tags('', ', ', ''); ?><?php } ?>-->
    
    <div class="cat"><span><?php the_category(', ') ?></span></div>
    <div class="clearfix"></div>
    
    </div>
    <?php endwhile; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Have you looked at using Category Templates. The Template Hierarchy will automatically use the proper Category Template and adhere to the show posts per page as defined in Settings->General.

    Change to the WordPress Default theme to see it in action.

    Just in case, that isn’t sufficient, I think this would work:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $recentPosts = new WP_Query();
    $recentPosts->query('cat=12&paged=' . $paged);

    See template tag, query_posts(), for more info.

    Thanks for the response! I will check out the Category templates and if those do not work well for me I’ll return to the code. Thanks again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHPExec Categories – Multipage?’ is closed to new replies.
Skip to toolbar