Support » Fixing WordPress » Post Content And Template Tags Determined By Category?

  • Hi, I’m completely new to WP and PHP and I’m getting a late night head ache trying to figure out the following brain teaser. Any help would be greatly appreciated!

    I am using the excerpt field for a user uploaded image file name. This file name will then be added like this: <img src="<?php the_excerpt(); ?>"> . This allows me to add the cover of an album to a review post, with each new post refering to an image in the above folder to accompany the review body.


    I only want to do this on posts that are in my Reviews catergory. Otherwise, when I check (for instance) my news posts, I get the tiny icon to tell me that an image file name does not exist (as it’s only entered for reviews and for every other category its left blank).

    So. Is it possible to somehow specify on a category basis, if the excerpt (or other optional content) should be added or not?

    Also, is it still possible for me to use the default 120 word excertp ASWELL or is that just impossible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 1. You can use the default 120 word excerpt by replacing the_content() tag with the_excerpt(). See:

    2. Check the Conditional Tags for is_category() here:

    [NOTE: I’ve opted for custom fields to hold the URL for the CD cover, instead of the excerpt field.]

    I’ve tried the conditional tags, but I can’t seem to get them to work. I’ve added the following:

    <?php if (is_category('3'))
    echo "image file";
    echo "";

    So that if category 3 is being displayed, it shows the image and if its anything else, it replaces that with a blank space. However it only ever puts in the space (I changed it to a word to check) and it appears to ignore the category number.

    Any idea whats going wrong here?

    Lastly, I need for an image file to appear (not the words!) when true, however if I add:

    "<img src="<?php echo $post->post_customfieldone; ?>" class="alignleft">"

    It comes up with a parse error. I really am stumped.

    Apologies for the newbie-ness of this…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Content And Template Tags Determined By Category?’ is closed to new replies.