If statement not working in category header
-
On my homepage I am displaying the four most recent posts in selected categories on my homepage. I’ve got it working except for in the header of the category section. If a certain category is displayed then I want the image associated with that category to be displayed in the header instead of text.
For example, if the category beyond the mash is displayed and I want the image displayed instead the text.
However the current if statement I have placed in the header displays the image for beyond the mash in every category header.
Everything else is displaying popularly. I must be doing something wrong in my if statement. Any help would be greatly appreciated.
Below is the portion code I am using to create the header for the category section:
<?php $i = 0; ?> <?php $category_array = get_option('blog_style_1'); ?> <?phy_array != false){ ?> <?php foreach ($category_array as $cat) { ?> <?php //$category_id = get_cat_ID($category_array[$i]); ?> <?php $category_id = $category_array[$i]; ?> <?php $cat_name = get_cap if($categort_name($category_array[$i]); ?> <?php $cat_link = get_category_link($category_array[$i]); ?> <?php $featured = new WP_Query('showposts=1&cat='.$category_id.''); while($featured ->have_posts()) : $featured->the_post(); ?> <div class="cat_listing"> <div class="header"> <?php if ($cat_name = ('beyond-the-mash')) { echo '<img src="http://www.stimadesigns.com/hunterdonbrewing/wp-content/uploads/2016/02/BeyondtheMash.png" />' ; } elseif ($cat_name = ('drinks-and-drams')) { echo '<img src="http://www.stimadesigns.com/hunterdonbrewing/wp-content/uploads/2016/02/DrinksandDreams.png" />' ;} else { ?> <h1><a href="<?php echo $cat_link; ?>"><?php echo $cat_name; ?></a></h1> <?php ;} ?> </div><!-- #header -->
The topic ‘If statement not working in category header’ is closed to new replies.