Title: php help
Last modified: August 21, 2016

---

# php help

 *  Resolved [rebelyun](https://wordpress.org/support/users/rebelyun/)
 * (@rebelyun)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/php-help-21/)
 * Hello, can anyone assist me with this code?
 * I’m trying to modify it so that when a post is labeled under a certain category,
   it will remove the timestamp and author.
 *     ```
       <?php get_header(); ?>
       	<div id="single_cont">
   
       		<div class="single_left">
   
       			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       				<h1 class="single_title"><?php the_title(); ?></h1>
       <?php the_time('m/j/y'); ?> at <?php the_time('G:i'); ?> by <?php the_author() ?>
       				<div class="single_inside_content">
       				<?php the_content(); ?>
       				</div><!--//single_inside_content-->
       				<br /><br />
       				<?php comments_template(); ?>
       			<?php endwhile; else: ?>
       				<h3>Sorry, no posts matched your criteria.</h3>
       			<?php endif; ?>                    
   
       		</div><!--//single_left-->
   
       		<?php get_sidebar(); ?>
   
       		<div class="clear"></div>
   
       	</div><!--//single_cont-->
   
       <?php get_footer(); ?>
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550345)
 * See [http://codex.wordpress.org/Template_Tags/in_category](http://codex.wordpress.org/Template_Tags/in_category)
 *  Thread Starter [rebelyun](https://wordpress.org/support/users/rebelyun/)
 * (@rebelyun)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550367)
 * thanks for the reference but although relevant it didn’t seem to really give 
   me an idea of how to proceed. I modified the php now to look like this and now
   the page shows a syntax error. Anyone have an idea as to what my novice mind 
   did wrong?
 *     ```
       <?php get_header(); ?>
       	<div id="single_cont">
       		<?php if ( in_category('curriculum vitae') ) {
       	include 'single-cat-custom.php';
       } else {
       		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       				<h1 class="single_title"><?php the_title(); ?></h1>
       		<div class="datetime">
       <?php the_time('m/j/y'); ?> at <?php the_time('G:i'); ?>
       </div>
       				<div class="single_inside_content">
       				<?php the_content(); ?>
       				</div><!--//single_inside_content-->
       				<br /><br />
       				<?php comments_template(); ?>
       			<?php endwhile; else: ?>
       				<h3>Sorry, no posts matched your criteria.</h3>
       			<?php endif; ?>
       		</div><!--//single_left-->
       		<?php get_sidebar(); ?>
   
       		<div class="clear"></div>
   
       	</div><!--//single_cont-->
   
       <?php get_footer(); ?>
       ```
   
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550386)
 * You started a new PHP block, but never closed it, like so:
 *     ```
       <?php if ( in_category('curriculum vitae') ) {
       	include 'single-cat-custom.php';
       } else { ?>
       		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       ```
   
 * Or run the two adjacent blocks together like so:
 *     ```
       } else {
       		if (have_posts()) : while (have_posts()) :
       ```
   
 * In a similar vein, you opened a curly brace block after `else`, but I don’t see
   where it was closed. You probably need to insert `<?php } ?>` towards the bottom
   somewhere. Unless you did and I’m just not seeing it.
 *  Thread Starter [rebelyun](https://wordpress.org/support/users/rebelyun/)
 * (@rebelyun)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550389)
 * Thanks for getting back to me.
 * I tried your first solution however I got the same syntax error on line 26.
 *     ```
       <?php get_header(); ?>
       	<div id="single_cont">
       		<?php if ( in_category('curriculum vitae') ) {
       	include 'single-cat-custom.php';
       } else { ?>
       		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       				<h1 class="single_title"><?php the_title(); ?></h1>
       		<div class="datetime">
       <?php the_time('m/j/y'); ?> at <?php the_time('G:i'); ?>
       </div>
       				<div class="single_inside_content">
       				<?php the_content(); ?>
       				</div><!--//single_inside_content-->
       				<br /><br />
       				<?php comments_template(); ?>
       			<?php endwhile; else: ?>
       				<h3>Sorry, no posts matched your criteria.</h3>
       			<?php endif; ?>
       		</div><!--//single_left-->
       		<?php get_sidebar(); ?>
   
       		<div class="clear"></div>
   
       	</div><!--//single_cont-->
   
       <?php get_footer(); ?>
       ```
   
 * any thoughts?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550464)
 * You opened a curly brace block after `else`, it is not closed. You need to insert`
   <?php } ?>` towards the bottom somewhere.
 *  Thread Starter [rebelyun](https://wordpress.org/support/users/rebelyun/)
 * (@rebelyun)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550466)
 * I tried it but it didn’t seem to have any effect. I figured it out at least. 
   For anyone else looking I uploaded two more php files. One with the modification
   to the single.php I needed and the other just a backup of the original coding.
 * I then opened up single.php and inserted:
 *     ```
       <?php get_header(); ?>
   
       	<?php
               if ( have_posts() ) { the_post(); rewind_posts(); }
               if ( in_category(11) ) {
                   include(TEMPLATEPATH . '/single-cat-custom.php');
               }
               else {
                   include(TEMPLATEPATH . '/single-default.php');
               }
           ?>
   
       <?php get_footer(); ?>
       ```
   
 * Hope this helps anyone else looking to make specific changes to a post specific
   to a category.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘php help’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 3 participants
 * Last reply from: [rebelyun](https://wordpress.org/support/users/rebelyun/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/php-help-21/#post-4550466)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
