Wordpress: Changing category layout theme with PHP -
i have category.php page use same layout have homepage. several attempts edit code myself failed, googled several sites , topics on here explain how edit layout of category template scratch, have theme problem how edit code exists.
this original archive/category code
<?php get_header(); ?> <?php // blog layout theme options if(get_theme_mod('asw_sidebar_pos', 'sidebar-right') != 'none'){ $sidebar_pos = get_theme_mod('asw_sidebar_pos', 'sidebar-right').' span9'; } else { $sidebar_pos ='span12'; } ?> <div id="page-wrap" class="container"> <div id="content" class="<?php echo esc_attr($sidebar_pos); ?>"> <div class="row-fluid"> <?php if (have_posts()) : ?> <div class="archive-header span12"> <?php if ( is_category() ) { $archive_title = single_cat_title('', false); $categories = get_category( get_query_var( 'cat' ) ); $catid = $categories->cat_id; $args = array( 'current_category' => $catid, 'echo' => 0, 'title_li' => "" ); echo '<div class="post-count"><h2>'.$wp_query->found_posts.' '.esc_html__('posts', 'larue').' '.esc_html__('in', 'larue').' '.$archive_title.'</h2></div><ul class="list-categories">'.wp_list_categories($args).'</ul>'; } elseif( is_tag() ){ $archive_title = single_tag_title('', false); echo '<div class="post-count"><h4>'.$wp_query->found_posts.' '.esc_html__('posts', 'larue').' '.esc_html__('for tag', 'larue').'</h4><h2>'.$archive_title.'</h2></div>'; } ?> </div> <?php while (have_posts()) : the_post(); get_template_part('templates/posts/content',get_post_format()); endwhile; echo '<div class="clearfix"></div>'; ?> <?php else : ?> <h2><?php esc_html_e('not found', 'larue') ?></h2> <?php endif; ?> </div> <?php get_template_part( 'framework/inc/nav' ); ?> </div> <?php if(get_theme_mod('asw_sidebar_pos', 'sidebar-right') != 'none'){ get_sidebar(); } ?> </div> <?php get_footer(); ?>
and code of layout wanted apply on above. can 1 point me in right direction?
<?php /** * template name: page: blog list */ ?> <?php get_header(); ?> <?php // blog layout theme options if(get_theme_mod('asw_sidebar_pos', 'sidebar-right') != 'none'){ $sidebar_pos = get_theme_mod('asw_sidebar_pos', 'sidebar-right').' span9'; } else { $sidebar_pos ='span12'; } if(get_theme_mod('asw_home_slider', true)) {?> <div class="wrapper"> <?php if (have_posts()) : while (have_posts()) : the_post(); if(empty($paged) or $paged < 2){ the_content(); } endwhile; endif;?> </div> <?php } //end slider output if ?> <div id="page-wrap" class="container"> <div id="content" class="<?php echo esc_attr($sidebar_pos); ?>"> <?php global $post; if ( is_front_page() ) { $paged = (get_query_var('page')) ? get_query_var('page') : 1; } else { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; } $args = array( 'post_type' => 'post', 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => $paged, 'post_status' => 'publish' ); if($paged != 1) { $offset = get_option( 'posts_per_page' ) + (($paged - 2) * 4); $args = array( 'posts_per_page' => 4, 'offset' => $offset, 'ignore_sticky_posts' => true ); } static $post_section_id = 0; $out = ''; ++$post_section_id; query_posts( $args ); if( have_posts() ) { echo '<div id="list-posts-'.$post_section_id.'" class="row-fluid list-posts">'; while ( have_posts() ) { the_post(); $categories = get_the_category(); $classes = join(' ', get_post_class($post->id)); echo '<article itemscope itemtype="http://schema.org/article" class="span12 post">'; echo '<div class="post-content-container">'; if( has_post_thumbnail() ) { echo '<figure class="post-img"><a href="'.esc_url(get_the_permalink()).'" rel="bookmark">'.get_the_post_thumbnail($post->id, 'medium').'</a></figure>'; } else { echo '<figure class="post-img"><a href="'.esc_url(get_the_permalink()).'" rel="bookmark"><img src="https://placeholdit.imgix.net/~text?txtsize=42&txt=your+image+here&w=470&h=410" alt="placeholder image"></a></figure>'; } echo '<div class="extra-wrap">'; if ( ! empty( $categories ) ) { $category = '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>'; echo '<div class="meta-categories">'.$category.'</div>'; } echo '<header class="title"><h2 itemprop="headline"><a href="'.esc_url(get_the_permalink()).'" title="'.esc_html__('permalink to', 'larue').' '.esc_attr(the_title_attribute('echo=0')).'" rel="bookmark">'.esc_attr(the_title_attribute('echo=0')).'</a></h2></header>'; echo '<div class="meta">'; echo '<span class="meta-date"><time datetime="'.esc_attr(date(date_w3c)).'">'.esc_attr(get_the_time(get_option('date_format'))).'</time></span>'; echo '<span class="meta-comments">'.laruecommentsnumber($post->id).'</span>'; echo '</div>'; echo '<div class="post-content">'; echo '<div class="post-excerpt">'.larueexcerpt(29).'</div>'; wp_link_pages(array('before' =>'<div class="pagination_post">', 'after' =>'</div>', 'pagelink' => '<span>%</span>', 'echo' => true)); echo '<a href="'.esc_url(get_the_permalink()).'" class="button post-more-button">'.esc_html__('view post','larue').'</a>'; echo '</div></div>'; echo '</div>'; echo '</article>'; } echo '</div>'; } echo '<div id="pagination-list"><div id="pagination" class="hide">'.get_next_posts_link().'</div>'; echo '<a href="#" class="loadmore">'.esc_html__('load more','larue').'</a></div>'; wp_reset_query(); ?> </div> <?php if(get_theme_mod('asw_sidebar_pos', 'sidebar-right') != 'none'){ get_sidebar(); } ?> </div> <?php get_footer(); ?>
Comments
Post a Comment