Jump to content

Could someone help me with this code I am trying for a wordpress site?


mistafro

Recommended Posts

I have a wordpress site that has a ribbon graphic on the index page posts that are in the category "features", it works great when it's like this:

<?php //for better seo, we use alt and titles in h
                query_posts('category_name=features&showposts=4');
                while(have_posts()):the_post();
                $attrs = array(
            'src'    => $src,
            'class'    => "",
            'alt'    => get_the_title(),
            'title'    => get_the_title(),
        );?>

            <!-- Blog entry -->
            <div class="blog_entry">

                <!-- inside -->
                <div class="inside">            


                <!-- Thumbnail -->
                <div class="thumbnail">
                   <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_post_thumbnail('blogsmall', $attr );?></a>
                </div>
                <!-- /Thumbnail -->

                <!-- Resume -->
                <div class="resume"><div class="featured_banner2"></div>
                    <h3 class="cufon"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
                    <p class="bigline"><?php the_excerpt();?></p>
                    <br>
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
                </div>
                <!-- /Resume -->

 

but when going to the category view it doesn't work to just add the

<div class="featured_banner2"></div>

as all post types get the ribbon.

 

So I am trying to use a PHP if statement to only apply that featured_banner2 div line to posts with the category name of "features"

 

I am a total php newbie, so far I tried this but it obviously is not right, I am trying though! lol:

 

<!-- Resume -->
            	<div class="resume">
            	 <?php 
            	 if ( in_category( 'features' )) {
            	   <div class="featured_banner2"></div>
            	    } 
            	         endif;?>

                	<h3 class="cufon"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
                    <p class="bigline"><?php echo  get_the_excerpt();?></p>
                </div>
        		<!-- /Resume -->

 

you want to parse a HTML division. You could you something like

if ( in_category( 'features' )) {
            	   echo '<div class="featured_banner2"></div>';
            	    } 

 

But PHP is faster parsing HTML instead of print HTML time after time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.