I do a lot of work with Thesis theme and now they have a Custom Loop API which makes it even better than it was before. While I am not a php guru by any means I have managed to put this [awesome] structure for category pages together. I commented it so that people would know what is going on….the result is at the bottom so you know what it looks like…style it as your please…
The final code:
//CUSTOM CATEGORY LOOP//
$loopty_loop = new seans_loop; //START THE LOOP
function bm_dont_display_it($content) { //START THE FILTER TO NOT SHOW CATEGORIES IF THERE ARE NONE
if (!empty($content)) {
$content = str_ireplace('<li>' .__( "No categories" ). '</li>', "", $content);
}
return $content;
}
add_filter('wp_list_categories','bm_dont_display_it');//END THE FILTER TO NOT SHOW CATEGORIES IF THERE ARE NONE
class seans_loop extends thesis_custom_loop {
function category() {
if ( is_category() && !is_paged() ) {
thesis_archive_intro();
echo "<div class=\"post_box top\">\n";
echo "\t<div class=\"format_text\">\n";
echo "\t<div class=\"artz\">\n"; //MAKE A DIV AROUND RECENT ARTICLES SO I CAN FLOAT SIDE BY SIDE WITH SUBCATEGORIES
echo "<h3>Related Articles:</h3>";
echo "\t\t<ul>\n";
while (have_posts()) {
the_post();
echo "\t\t\t<li><a href=\"" . get_permalink() . "\">" . get_the_title() . "</a></li>\n";
}
echo "\t\t</ul>\n";
echo "\t</div>\n"; //ENDS THE RELATED POSTS DIV
//this is where I start the if statment for the subcategories...if I can ever figure this fucking thing out
echo "\t<div class=\"subs\">\n"; //MAKE A DIV AROUND SUB CATTYS SO I CAN FLOAT SIDE BY SIDE WITH ARTICLES
echo "<h3>Sub Categories:</h3>"; //H3 FOR NAME OF SUBCATEGORIES
$cat_id = get_query_var('cat'); //GET THE CURRENT SUB CATTY DYNAMICALLY
wp_list_categories('orderby=id&show_count=0&hide_empty=1&use_desc_for_title=0&hierarchical=0&title_li=&child_of=' . $cat_id); //LIST THE SUBCATEGORIES
echo "\t</div>\n"; //ENDS THE SUB CATTYS DIV
//add another if statement for the rest of the stuff if you get the 1list part on line 592
echo "\t</div>\n";
echo "</div>\n";
}
if ( is_category() && is_paged() ) {
echo "<div class=\"post_box top\">\n";
echo "\t<div class=\"format_text\">\n";
echo "<h3>Related Articles:</h3>";
echo "\t\t<ul>\n";
query_posts('posts_per_page=20'); //THIS SETS OUT THE AMOUNT OF POSTS WE WANT TO SHOW WHEN THE PAGE IS_PAGED
while (have_posts()) {
the_post();
echo "\t\t\t<li><a href=\"" . get_permalink() . "\">" . get_the_title() . "</a></li>\n";
}
echo "\t\t</ul>\n";
echo "\t</div>\n";
echo "</div>\n";
}
}
}
//END THE CUSTOM CATEGORY LOOP//
and here is the CSS I used to float it next to each other:
.subs{
float:right;
width:49%;
}
.subs li.cat-item {
list-style: disc outside url("http://www.startuploans.org/images/list.gif");
margin: 0 10px 0 60px;
}
.artz{
float:left;
width:49%;
}
The Result for main category Page:

The result for pages that are paged (is_paged):

Here are also some articles that helped me get to where I needed to be and understand everything:
So, there you have it- a custom category loop using Thesis Theme 1.8+ Custom Loop API.
Top Rated Comments