• hello, i’m needing a little bit of help with my categories.php file loop.

    currently i’m using 20 different categories files, one for each category, simply to loop the results. here’s the code i’m using:

    <?php $categories = get_categories("child_of=23"); foreach ($categories as $cat) { ?>
    	<div class="genre_subcat">
    		<?php query_posts("cat=$cat->cat_ID&showposts=-1&order=ASC&orderby=name"); ?>
    		<h3 class="cat-page-<?php single_cat_title(); ?>"><?php single_cat_title(); ?></h3>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="post">
    				<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
    				<a class="imagen" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php echo get_the_post_thumbnail($page->ID, array(120,120) ); ?></a>
    				<?php the_meta(); ?>
    			</div>
    		<?php endwhile; ?>
    	</div>
    <?php }?>

    the ONLY thing that varies in each category file is the “child_of=23” part of the code… since that part of the code is what calls the specific category results for each cat-page result…

    i want to have a single category.php file that does this but i’m not very good with php so i’m having some trouble.

    what i was thinking of doing is maybe some thing like:

    if x category, then use x loop… if y category, then use y loop, etc… i would be repeating this if loop 20 times since i have 20 category page results but at least it would all be in a single file!

    i hope someone can understand my problem and help me out. and if they have a better solution then that would be awesome! (i know there is one but im not very good with php)…

    thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • nfa1218,

    Hello there. I am curious what would change inside your different category loops? Knowing this will lead to the best answer.

    Thread Starter nfa1218

    (@nfa1218)

    hi, the number that changes in the “child_of=23” part of the code is the ID number for the category that i want. that is the only part of the code that i’m changing in each of my category loops…

    i have one category which hold all my blog entries… which will have one type of css style… and 20 different categories for different types of services which will have a different css style and also each one of those will have different color indicating the service…

    hope that helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘help integrating many categories.php into one single .php file’ is closed to new replies.