Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The modified template for displaying Category pages.
- *
- * Display original if translation does not exist.
- *
- * Used to display archive-type pages for posts in a category.
- *
- * @link http://codex.wordpress.org/Template_Hierarchy
- *
- * @package WordPress
- * @subpackage Twenty_Twelve
- * @since Twenty Twelve 1.0
- */
- get_header();
- // WPML support
- global $sitepress;
- // save current language
- $current_lang = $sitepress->get_current_language();
- //get the default language
- $default_lang = $sitepress->get_default_language();
- //fetch posts in default language
- $sitepress->switch_lang($default_lang);
- $cat = get_query_var('cat');
- //query args
- $custom_query_args = array(
- 'cat' => icl_object_id($cat, 'category', FALSE,'en')
- );
- //build query
- $custom_query = new wp_query($custom_query_args);
- //\ WPML support
- ?>
- <section id="primary" class="site-content">
- <div id="content" role="main">
- <?php
- // WPML support
- if ( $custom_query->have_posts() ) :
- //\ WPML support
- ?>
- <header class="archive-header">
- <h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>
- <?php if ( category_description() ) : // Show an optional category description ?>
- <div class="archive-meta"><?php echo category_description(); ?></div>
- <?php endif; ?>
- </header><!-- .archive-header -->
- <?php
- /* Start the Loop */
- // WPML support
- while ( $custom_query->have_posts() ) : $custom_query->the_post();
- //check if a translation exist
- $t_post_id = icl_object_id($post->ID, 'post', false, $current_lang);
- if(!is_null($t_post_id)){
- // get the post object
- $t_post = get_post( $t_post_id);
- // include the output code
- include (get_stylesheet_directory() . '/content-t.php');
- }
- //no translation? display default language
- else{
- /* Include the post format-specific template for the content. If you want to
- * this in a child theme then include a file called called content-___.php
- * (where ___ is the post format) and that will be used instead.
- */
- get_template_part( 'content', get_post_format() );
- }
- endwhile;
- wp_reset_query();
- $sitepress->switch_lang($current_lang);
- //\ WPML support
- twentytwelve_content_nav( 'nav-below' );
- ?>
- <?php else : ?>
- <?php get_template_part( 'content', 'none' ); ?>
- <?php endif; ?>
- </div><!-- #content -->
- </section><!-- #primary -->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement