• Resolved Niclas

    (@najclas)


    I’m sorry for #2 support-request in a really short amount of time. It’s almost time to start paying for the awesome support I’m getting.

    Anyway, this time I want to decide how many posts I display on the page (using that category-x.php).

    What I’ve done now is:

    <?php
    $myposts = get_posts('numberposts=1&category=3');
    foreach($myposts as $post) :
    ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    	<h3 class="storytitle"><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h3>
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    
    </div>
    <?php endforeach; ?>

    and it works the way I like it to, except the titles and permalinks who all link to the latest post and display the latest posts title. Is there any else better, more optimized way to do this or am I just missing some simple line of code?

Viewing 4 replies - 1 through 4 (of 4 total)
  • That’s one way. Although quite overcomplicated.
    1. You do NOT have to tell on a category template which posts to show: WP knows better than you ??
    Actually, saving the simplest archive.php as category-x.php would do the job.
    2. No need to reinvent the wheel… query_posts
    3. There is also a plugin CQS (custom query string) to set diff # of posts on different views…

    Thread Starter Niclas

    (@najclas)

    moshu, thank you once again! You are truly a masterpiece ??

    However, since I’m not comfortable with that query_posts thing I tried using the plugin, but it won’t work under 2.3.1 and gives me a error when I try to change the amount of posts displayed when seeing a category:

    WordPress database error: [Table 'wordpress.wp_categories' doesn't exist]
    SELECT cat_ID FROM wp_categories WHERE category_nicename = 'basics'

    Anybody got a clue what may help? I know that the plugin is currently unsupported by the developer, and that recent changes in wp 2.3 may have broken the plugin – but I’m crossing my fingers someone out there has a solution to my problem ??

    thanks once again!

    Try this version (2.7.2) – no guarantee, although it worked on a local install…
    https://www.transycan.net/blogtest/download-themes/

    Thread Starter Niclas

    (@najclas)

    you are a true master moshu.
    is there some way I can repay you for the help you’ve given?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display x ammount of posts’ is closed to new replies.