July 11, 201016 yr Oh boy I can't believe how complicated Wordpress makes this stuff Anyway I am following the instructions here to get round Wordpress wanting all my single posts to have the same template. I have added two new files to my theme templates = single1.php and single3.php - these are exact copies of the original single.php so there should be no problem with these files. Then I have edited single.php as per instructions but changing TEMPLATEPATH to STYLESHEETPATH because I am using a child theme. So my single.php now looks like this... <?php $post = $wp_query->post; if ( in_category('3') ) { include(STYLESHEETPATH . '/single3.php'); } else { include(STYLESHEETPATH . '/single1.php'); } ?> Can anyone please tell me if this code looks ok because when I click any of my single posts I get a blank screen. thank you
July 11, 201016 yr change stylesheet in the path to either of the below <?php include bloginfo('template_directory'); ?>/filename.php <?php include( TEMPLATEPATH . '/filename.php' ); ?> Add the folder name before the file name, if the file is in a folder e.g. <?php include( TEMPLATEPATH . '/header2.php' ); ?>/folder/filename.php
July 11, 201016 yr Author change stylesheet in the path to either of the below Thanks for suggestions but single.php [edit]= <?php $post = $wp_query->post; if ( in_category('3') ) { <?php include bloginfo('template_directory'); ?>/single3.php } else { <?php include bloginfo('template_directory'); ?>/single1.php } ?> = white screen <?php $post = $wp_query->post; if ( in_category('3') ) { include(TEMPLATEPATH . '/single3.php'); } else { include(TEMPLATEPATH . '/single1.php'); } ?> = white screen. And single1.php / single3.php are not in a folder. Anyway I think i found a way round with a Single Post Template plugin. thanks Edited July 11, 201016 yr by Juc1
July 11, 201016 yr Thanks for suggestions but sidebar.php = <?php $post = $wp_query->post; if ( in_category('3') ) { <?php include bloginfo('template_directory'); ?>/single3.php } else { <?php include bloginfo('template_directory'); ?>/single1.php } ?> = white screen thanks remove the php tags e.g. change to <?php $post = $wp_query->post; if ( in_category('3') ) { include bloginfo('template_directory'); ?>/single3.php } else { include bloginfo('template_directory'); ?>/single1.php } ?>
July 11, 201016 yr Author remove the php tags e.g. change to <?php $post = $wp_query->post; if ( in_category('3') ) { include bloginfo('template_directory'); ?>/single3.php } else { include bloginfo('template_directory'); ?>/single1.php } ?> single.php = <?php $post = $wp_query->post; if ( in_category('3') ) { include bloginfo('template_directory'); ?>/single3.php } else { include bloginfo('template_directory'); ?>/single1.php } ?> = Any single post gives a white page. thanks
July 11, 201016 yr single.php = <?php $post = $wp_query->post; if ( in_category('3') ) { include bloginfo('template_directory'); ?>/single3.php } else { include bloginfo('template_directory'); ?>/single1.php } ?> = Any single post gives a white page. thanks Must be something up with your other code then, as that should grab the single3.php file. Is the file in the root of the theme e.g. wp-content themes theme-name theme-file.php Also try this instead of your query <?php query_posts('posts_per_page=2'); ?> To edit it, just add anything from thispage
July 11, 201016 yr Author Must be something up with your other code then, as that should grab the single3.php file. Is the file in the root of the theme e.g. wp-content themes theme-name theme-file.php wp-content/themes/titan_pro/single1.php wp-content/themes/titan_pro/single3.php = <?php get_header(); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-header"> <div class="tags"><?php the_tags( '<span>Tags</span> <p>', ', ', '</p>'); ?></div> <h1><?php the_title(); ?></h1> <div class="author"><?php printf(__ ( 'by %s on', 'titan'), get_the_author()); ?> <?php the_time(__ ( 'F jS, Y', 'titan')); ?></div> </div><!--end post header--> <div class="entry clear"> <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( array(250,9999), array( 'class' => ' alignleft border' )); ?> <?php the_content(__( 'read more...', 'titan')); ?> <?php edit_post_link(__( 'Edit', 'titan')); ?> <?php wp_link_pages(); ?> </div><!--end entry--> <div class="meta clear"> <p><?php _e( 'From', 'titan' ); ?> → <?php the_category( ', '); ?></p> </div><!--end meta--> </div><!--end post--> <?php endwhile; /* rewind or continue if all posts have been fetched */ ?> <?php comments_template( '', true); ?> <?php else : ?> <?php get_sidebar(); ?> <?php get_footer(); ?> thanks
July 11, 201016 yr Author update - I tried this on another install... single.php = <?php include (STYLESHEETPATH . '/sidebar2.php'); ?> Click on single post = gives the sidebar as expected. single.php = <?php include (STYLESHEETPATH . '/single1.php'); ?> Click on single post = white page. This tells me there is something wrong with single1.php...
July 11, 201016 yr Author Must be something up with your other code then Yes you are correct. Thanks for your help and I apologise for wasting your time in telling you that single1.php was ok when it wasn't. single1.php now working ok = <?php get_header(); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-header"> <div class="tags"><?php the_tags( '<span>Tags</span> <p>', ', ', '</p>'); ?></div> <h1><?php the_title(); ?></h1> <div class="author"><?php printf(__ ( 'by %s on', 'titan'), get_the_author()); ?> <?php the_time(__ ( 'F jS, Y', 'titan')); ?></div> </div><!--end post header--> <div class="entry clear"> <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( array(250,9999), array( 'class' => ' alignleft border' )); ?> <?php the_content(__( 'read more...', 'titan')); ?> <?php edit_post_link(__( 'Edit', 'titan')); ?> <?php wp_link_pages(); ?> </div><!--end entry--> <div class="meta clear"> <p><?php _e( 'From', 'titan' ); ?> → <?php the_category( ', '); ?></p> </div><!--end meta--> </div><!--end post--> <?php endwhile; /* rewind or continue if all posts have been fetched */ ?> <?php comments_template( '', true); ?> <?php else : ?> <?php endif; ?> </div><!--end content--> <?php get_sidebar(); ?> <?php get_footer(); ?> The bad single1.php posted above was missing the lines... <?php endif; ?> </div><!--end content-->
July 11, 201016 yr Yes you are correct. Thanks for your help and I apologise for wasting your time in telling you that single1.php was ok when it wasn't. single1.php now working ok = <?php get_header(); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-header"> <div class="tags"><?php the_tags( '<span>Tags</span> <p>', ', ', '</p>'); ?></div> <h1><?php the_title(); ?></h1> <div class="author"><?php printf(__ ( 'by %s on', 'titan'), get_the_author()); ?> <?php the_time(__ ( 'F jS, Y', 'titan')); ?></div> </div><!--end post header--> <div class="entry clear"> <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( array(250,9999), array( 'class' => ' alignleft border' )); ?> <?php the_content(__( 'read more...', 'titan')); ?> <?php edit_post_link(__( 'Edit', 'titan')); ?> <?php wp_link_pages(); ?> </div><!--end entry--> <div class="meta clear"> <p><?php _e( 'From', 'titan' ); ?> → <?php the_category( ', '); ?></p> </div><!--end meta--> </div><!--end post--> <?php endwhile; /* rewind or continue if all posts have been fetched */ ?> <?php comments_template( '', true); ?> <?php else : ?> <?php endif; ?> </div><!--end content--> <?php get_sidebar(); ?> <?php get_footer(); ?> The bad single1.php posted above was missing the lines... <?php endif; ?> </div><!--end content--> Glad you got it working, sometimes we need to test everything around the code before we can get it to finally work
Create an account or sign in to comment