• Resolved laojocelyn

    (@laojocelyn)


    Hi,

    I’ve been using a conditional tag in my loop.php file to modify the height and width of my featured image for a particular category, as below:

    if (is_category('Lifestyle 生活方式')) {
    ! get_the_image( array( 'size' => 'thumbnail', 'width' => 25, 'height' => 25, 'before' => '<div class="cover">', 'after' => '</div>' ) );
    }else{
    get_the_image( array( 'size' => 'thumbnail', 'width' => 228, 'height' => 160, 'before' => '<div class="cover">', 'after' => '</div>' ) ); } ?>

    I have two questions I hope will be fairly easy to answer!

    1. Rather than resize the image, is it possible to actually hide it (or the div) modifying the code above, just for that category?

    2. On this page, I can’t seem to ‘target’ the category like above. I’ve tried if (is_category('SD俚语词典')) but no luck. The category is created by an Encyclopedia plugin so i think this may be the reason. I’m stumped!

    Thank you for any help you’re able to give. I’ve only been delving into php for about 10 hours so any help is very much appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • 1. Like this?

    if (is_category('Lifestyle 生活方式')) {
         //do nothing
    }else{ ...

    2. This might be the problem:
    is_category(): This Conditional Tag checks if a Category archive page is being displayed
    in_category(): Tests if the current post (or any specified post) is assigned to any of the specified categories.

    Thread Starter laojocelyn

    (@laojocelyn)

    1. Thanks Peter – that solved my problem!

    2. Ah yes I tried both but no luck.

    Thanks for reading over my problem and helping me out!

    Hmm, well the page you showed as an example seems to be a category page. So only posts of the category ‘slang’ should be shown on that page. What exactly are you trying to do?

    Thread Starter laojocelyn

    (@laojocelyn)

    On the ‘slang’ page, I’m trying to remove the !!! image.
    It’s not a specific featured image, just an image in the main body of the post that appears to be automatically set as the featured image.

    The category(s) for all posts on the page were created within the plugin, (not the regular categories) so I imagine this is what’s the problem.

    Thread Starter laojocelyn

    (@laojocelyn)

    worked it out using good ol’ Firebug.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Excluding categories and specific plugin categories.’ is closed to new replies.