Support » Fixing WordPress » If Else Statement on single.php

  • Hello,

    Using child them of gridster-lite theme.

    Trying to load two different post types. If category id = 8 load standard post type, else load new post type. My single.php in my child theme looks like this;

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package Gridster
     */
    
    get_header(); ?>
    
    <?php get_sidebar(); ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    
    <?php if (is_category( '8' )) {
     get_template_part( 'content', 'single' );
    } else {
     get_template_part( 'content', 'property' );
    }
    ?>
    
    <?php endwhile; // end of the loop. ?>
    
    <?php get_footer(); ?>

    It loads the standard post type (content-single.php) no problem but when the new post type page loads it loses all formatting (not loading header, sidebar, footer, etc). I created an exact copy of the content-single.php and named it content-property.php and placed it in my child theme.

    Standard Post: http://www.irishlandsales.ie/wip/2014/03/a-normal-post/

    New Post Type: http://www.irishlandsales.ie/wip/2014/03/bulgaden-castle/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If Else Statement on single.php’ is closed to new replies.