help integrating many categories.php into one single .php file
-
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.
- The topic ‘help integrating many categories.php into one single .php file’ is closed to new replies.