Custom page with subcategories (4 posts)

  1. LeRah
    Posted 3 years ago #

    Hi all,

    i would like to make a custom page showing all subcategories of a certain category. also i want to show the latest 5 posts in the subcategory under the subcategory title.

    can anyone help me with this?

  2. Michael
    Forum Moderator
    Posted 3 years ago #

  3. LeRah
    Posted 3 years ago #

    thanks i'll check them out, but im no php expert so more help is appreciated.

    using the twentytwelve theme

  4. LeRah
    Posted 3 years ago #

    nvm i got it working with this code:

    	$categories = get_categories('child_of=2');
    	foreach ($categories as $cat) {
    		echo "<h3>" . $cat->name . "</h3>";
    		query_posts('cat=' . $cat->term_id);
    		while (have_posts()) : the_post();
    			<a href="<? the_permalink(); ?>" title="<? the_title(); ?>"><? the_title(); ?></a><br />

    but when i change the while loop to only show 5 posts it shows the parent category's name instead :S

    is there a better way of doing this??

Topic Closed

This topic has been closed to new replies.

About this Topic