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 -->

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.