<?php
/**
 * This file is used for your faq post and entries
 * @package Ultra WordPress Theme
 * @since 1.0
 * @author AJ Clarke : http://wpexplorer.com
 * @copyright Copyright (c) 2012, AJ Clarke
 * @link http://wpexplorer.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

/******************************************************
 * Single Posts
 * @since 1.0
*****************************************************/
if ( is_singular('faq') && is_main_query() ) {
	
	// Show heading area unless disabled
	if ( get_post_meta( get_the_ID(), 'wpex_page_disable_heading', true ) !== 'yes' ) {
		$posttype_obj = get_post_type_object( get_post_type( ) ); ?>
        <header id="page-heading">
            <div class="boxed">
                <h1><?php the_title(); ?></h1>
                <?php
                // Yoast Breadcrumbs Support
                if( function_exists('yoast_breadcrumb') ) yoast_breadcrumb('<div id="breadcrumbs"><span class="icon-home"></span>','</div>'); ?>
                <ul id="post-pagination" class="clearfix">
                    <?php next_post_link('<li class="post-prev">%link</li>', '<span class="icon-arrow-left"></span>', false); ?>
                    <li class="postype-main"><a href="<?php echo get_post_type_archive_link( $post->post_type ); ?>" title="<?php echo $posttype_obj->label; ?>"><span class="icon-th-large"></span></a></li>
                    <?php previous_post_link('<li class="post-next">%link</li>', '<span class="icon-arrow-right"></span>', false); ?>
                </ul><!-- #post-pagination -->
            </div><!-- /boxed -->
        </header><!-- /page-heading -->    
    <?php } ?>
    
	<div id="single-faq-post" class="container boxed clearfix">
        <article id="post" class="clearfix">	
            <div class="faq-post-content entry">
                <?php the_content(); ?>
            </div><!-- .faq-post-content -->
			<?php
            // Show comments
            if ( of_get_option('faq_comments','') == '1' ) {
                comments_template();
            } ?>
			</article><!-- #post -->
			<?php
            // Load sidebar if post isn't full-width
            if( get_post_meta(get_the_ID(), 'wpex_post_layout', true ) !== 'Full Width' ) {
                get_sidebar();
            } ?>
	</div><!-- /single-post-wrap -->

<?php
/******************************************************
 * Entries
 * @since 1.0
*****************************************************/
} else {
	
	// Enque Javascript for the faq toggles
	wp_enqueue_script('faq-toggles'); ?>
    <article <?php post_class('faq-entry'); ?>> 
            <header class="faq-trigger"><h2><span class="icon-plus-sign-alt"></span><?php the_title(); ?></h2></header>
            <div class="faq-entry-content clearfix">
            <?php
				// Show excerpt if excerpt field isn't blank
				if ( !empty($post->post_excerpt) ) {
					echo apply_filters('the_content', get_the_excerpt()); ?>
                    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="faq-entry-readmore"><?php _e('read more','wpex'); ?> &rarr;</a>
				<?php
				// Otherwise show full content
                } else {
					the_content();
				} ?>
                
            </div><!-- .faq-entry-content -->
    </article><!-- .faq-entry -->
<?php } ?>