Title: help with in_category
Last modified: August 19, 2016

---

# help with in_category

 *  Resolved [raptrex](https://wordpress.org/support/users/raptrex/)
 * (@raptrex)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/help-with-in_category/)
 * so i have this code where i want it that if the post is in category 19, to get
   the custom field “linkurl”
    and for the rest of the categories, to display the
   tags this is my single.php
 *     ```
       <?php get_header(); ?>
       	<div id="content" class="post">
       		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
   
       			<div id="post-<?php the_ID(); ?>">
       				<h2><?php the_title(); ?></h2>
       					<?php the_content('<p>Read the rest of this entry &raquo;</p>'); ?>
       					<?php if (in_category('19)) { ?>
       					<div class="url">
       					<a href="<?php echo get_post_meta($post->ID, 'URL', TRUE); ?>" title="<?php the_title(); ?>"><?php the_title() ?></a>
       					</div>
       					<?php else { ?>
       					<div class="tags">
       						Tags:<?php the_tags('&nbsp; ',' &middot; ') ?>
       					</div>
       					<?php } ?>
       		<div id="commentsContainer">
       			<?php comments_template(); ?>
       		</div>
       		<?php endwhile; else: ?>
   
       			<h2>Sorry, the post could not be found.</h2>
   
       		<?php endif; ?>
   
       			</div>
       	</div>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 * however this is not working, im thinking its the in_category tag

Viewing 1 replies (of 1 total)

 *  Thread Starter [raptrex](https://wordpress.org/support/users/raptrex/)
 * (@raptrex)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/help-with-in_category/#post-976020)
 * lol nevermind i was missing a } in front of the else

Viewing 1 replies (of 1 total)

The topic ‘help with in_category’ is closed to new replies.

## Tags

 * [in_category](https://wordpress.org/support/topic-tag/in_category/)
 * [single.php](https://wordpress.org/support/topic-tag/single-php/)

 * 1 reply
 * 1 participant
 * Last reply from: [raptrex](https://wordpress.org/support/users/raptrex/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/help-with-in_category/#post-976020)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
