Hi all,
I am trying to call a function/loop specific to one category archive page. What I've done, is to remove the standard loop within my child-theme's functions.php, then replaced it with my 'special' loop.
So far, I have cracked getting that 'special' loop to work nicely. But what I want to do now, is to only run the function which rips out the normal loop when we are on the category archive of a particular category ('menus').
Here's my code:
// remove the standard loop
function remove_thematic_categoryloop() {
remove_action('thematic_categoryloop', 'thematic_category_loop');
}
add_action('init', 'remove_thematic_categoryloop');
// get the name of the category and store it in the variable $catslug
function add_handmade_intro_categoryloop() {
if (is_category( )) {
$cat = get_query_var('cat');
$yourcat = get_category ($cat);
$catslug = $yourcat->slug;
// loop for the content within the current category,
// which has a custom field 'intro_article' which is equal to 1
$handmade_query = new WP_Query('category_name='.$catslug.'&meta_key=intro_article&meta_value=1');
while ($handmade_query->have_posts()) : $handmade_query->the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content"><?php the_content(); ?></div>
<?php endwhile;
wp_reset_postdata(); ?>
<?php
// now loop to create an unordered list of the other posts in the category
// but which have a custom field 'intro_article' which is equal to 0
?>
<ul id="sub-nav-ul">
<?php
query_posts('category_name='.$catslug.'&meta_key=intro_article&meta_value=0');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li id="sub-nav" class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_post_thumbnail(array(70,70));?><span><?php the_title(); ?></span></a></li>
<?php endwhile; endif; ?></ul> <?php
}
}
add_action('thematic_categoryloop', 'add_handmade_intro_categoryloop');
So, I've tried to put in some "if (is_category('menus'))" stuff in before the function, which didn't work... and I have subsequently hit a wall and need some inspiration. I only want to call these functions if the category is 'menus'...
Can anybody help me get over this hump? it would save me some hair. Thanks!