[resolved] Search results, pages and categories (3 posts)

  1. I'm puzzled with this thing about search results and categories and pages.

    This snip below (parts of The Loop shown FWIW) doesn't show the default category "blog" that appears alongside a page that is in search results. Which is what I want.

    But this code snip also doesn't show the category of a post that does have a category, and I want that category show.

    <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
    <?php if (is_search()) { ?><?php } else { ?><?php is_category(); ?><?php } ?>
    <?php the_excerpt(); ?><?php endwhile; ?><?php else : ?>

    I've tried a bunch of variations of if and else and on and on. Anyone have some ideas?


  2. Bump...

  3. After beating my face on the keyboard of my MacBook until the case splintered (like it has anyway, without any additional abuse) and after the shards poked me all in the face and drew blood and caused pain until I had to run outside and stick my face in the snowbank outside my cabin in the wilderness of Montana, and after the grizzly bear - fresh from hibernation and hungry as all get out - scented my blood from a mile away and came running toward me, and after my trusty dog held it off, growling, until I could get inside and slam the door, the door with all the one foot sharp nails protruding through it (from the inside) to keep the bear from knocking the door down (which is a common feature of doors on cabins in the wilderness, by the way) and after my dog Blue (pictured at left) ran through the little dog door in the bottom (but one not big enough for a bear, you see), and after I wiped my face off and read the docs hosted on WordPress which describe how to work with complex conditonals and if else loops, I figured out how to do what I was asking above. Imagine that. Here it is, in case anyone else needs it:

    <?php if (in_category(1)) { ?><?php } elseif (is_category) { ?><?php $category = get_the_category(); echo $category[0]->cat_name; ?><?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic