WordPress.org

Ready to get started?Download WordPress

Forums

Codium Grid
[resolved] Categories page - category.php (9 posts)

  1. k00kaine
    Member
    Posted 5 months ago #

    Hello, is it possible to add the homepage sidebar to the category.php page? I use the category pages to show direct links to my post categories.

    Example - http://bargainocity.com/category/baby-kids/

    My question is if it's possible to get the sidebar in there. I've already looked in the category.php file and I actually see both <?php get_sidebar() ?> and <?php get_footer() ?> but neither of those show up on the page. Is there a trick or work around to adding it? If so any help would be appreciated. thanks

  2. rolzan
    Member
    Posted 5 months ago #

    Yes it is possible, can you post your index.php and category.php here?

    index.php and archive.php is the default for category.php if you don't have one, and it means that category.php is somewhat similar to archive.php and index.php, unless if you changed the structure.

  3. k00kaine
    Member
    Posted 5 months ago #

    Yeah I was kinda thinking it would be kinda similar, i jsut started getting a bit confused.

    Here is the indext.php

    <?php $count = 0; ?>
    
    <?php get_header( ); ?>
    	<div id="container" class="">
    		<div id="content" class="container_12 grid_10 push_5">
    			<?php if (have_posts()) :
    			while (have_posts()) : the_post();
    			$count++;
    			?>
    			<div class="grid_4 alpha<?php echo $count;?> omega<?php echo $count;?>">
                <!-- Category title only the fist one is display -->
    			<div <?php body_class('cat-links'); ?>>
                    <?php
                    $category = get_the_category();
                    if ($category ) {
                      echo '<a href="' . get_category_link( $category[0]->term_id ) . '" title="' . $category[0]->name . '" ' . '>' . $category[0]->name.'</a>';
                      if(isset($category[1])){
                        echo ' ...';
                      }
                    }
                    ?>
                </div>
    
    			<!-- Begin post -->
    			<div id="post-<?php the_ID(); ?>" <?php post_class('posthome'); ?>>
    				<?php if ( has_post_thumbnail() ) { ?>
    							<div class="">
    								<a href="<?php the_permalink(); ?>">
    									<?php
    										$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'post-thumbnail' );
                                            $title = get_the_title();
    	     								echo '<img src="' . $image_src[0]  . '" width="90%" alt="'.$title.'" />';
                                        ?>
    					        	</a>
    					    	</div><!-- End Thumb Container -->
    
    							<div class="posthometext">
    							<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Link to %s', 'codium_grid'), esc_html(get_the_title(), 1)) ?>" rel="bookmark"><?php echo codium_grid_short_title(get_the_title()); ?></a></h2>
    							<div class="entry-content-home">
    							<?php echo substr(get_the_excerpt(), 0,140); ?>
    							</div>
                                <?php if(get_the_title() == ''){ ?>
                                    <div class="entry-content-home">
    							        <a href="<?php the_permalink() ?>" title="<?php printf(__('read this post', 'codium_grid')) ?>" rel="bookmark">&raquo; <?php echo (__('read this post', 'codium_grid')) ?></a>
                                    </div>
                                <?php } ?>
    							</div>
    
                    <?php } else { ?>
    						<div class="posthometext">
    						<br />
    						<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Link to %s', 'codium_grid'), esc_html(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h2>
    							<div class="entry-content-home">
    							<?php echo substr(get_the_excerpt(), 0,140); ?>
    							</div>
                                <?php if(get_the_title() == ''){ ?>
                                    <div class="entry-content-home">
    							        <a href="<?php the_permalink() ?>" title="<?php printf(__('read this post', 'codium_grid')) ?>" rel="bookmark">&raquo; <?php echo (__('read this post', 'codium_grid')) ?></a>
                                    </div>
                                <?php } ?>
    						</div>
    
    					<?php }?> 
    
    			</div>
    			<!-- End post -->
    			</div>
    
    <?php endwhile; endif ?>
    
    <div class="clear"></div>				
    
    <div class="center">
    	<?php if(function_exists('wp_pagenavi')) {
    		wp_pagenavi();
    	} else {?>
    		<div class="navigation mobileoff"><p><?php posts_nav_link(); ?></p></div>
    		 <?php } ?>
    		<div class="navigation_mobile"><p><?php posts_nav_link(); ?></p></div>
    </div>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php get_sidebar() ?>
    <?php get_footer() ?>

    And here is the category.php

    <?php $count = 0; ?>
    <?php get_header( ); ?>
    	<div id="container" class="">
    		<div id="content" class="container_12 grid_10 push_5">
    			<h1 class="page-title"><?php
    					printf( __( '', 'codium_grid' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    			?></h1>
    			<div class="linebreak clear"></div>	
    
    			<?php
    					$category_description = category_description();
    					if ( ! empty( $category_description ) )
    						echo '<div class="entry-content">' . $category_description . '</div><div class="linebreak clear"></div>';
    
    			?>
    			<?php if (have_posts()) :
    			while (have_posts()) : the_post();
    			$count++;
    			?>
    			<div class="grid_4 alpha<?php echo $count;?> omega<?php echo $count;?>">
    			<!-- Category title only the fist one is display -->
    			<div <?php body_class('cat-links'); ?>>
                    <?php
                    $category = get_the_category();
                    if ($category ) {
                      echo '<a href="' . get_category_link( $category[0]->term_id ) . '" title="' . $category[0]->name . '" ' . '>' . $category[0]->name.'</a>';
                      if(isset($category[1])){
                        echo ' ...';
                      }
                    }
                    ?>
                </div>
    
    			<!-- Begin post -->
    			<div id="post-<?php the_ID(); ?>" <?php post_class('posthome'); ?>>
    				<?php if ( has_post_thumbnail() ) { ?>
    							<div class="">
    								<a href="<?php the_permalink(); ?>">
    									<?php
    										$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'post-thumbnail' );
                                            $title = get_the_title();
    	     								echo '<img src="' . $image_src[0]  . '" width="100%" alt="'.$title.'" />';
                                        ?>
    					        	</a>
    					    	</div><!-- End Thumb Container -->
    
    							<div class="posthometext">
    							<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Link to %s', 'codium_grid'), esc_html(get_the_title(), 1)) ?>" rel="bookmark"><?php echo codium_grid_short_title(get_the_title()); ?></a></h2>
    							<div class="entry-content-home">
    							<?php echo substr(get_the_excerpt(), 0,140); ?> [...]
    							</div>
                                <?php if(get_the_title() == ''){ ?>
                                    <div class="entry-content-home">
    							        <a href="<?php the_permalink() ?>" title="<?php printf(__('read this post', 'codium_grid')) ?>" rel="bookmark">&raquo; <?php echo (__('read this post', 'codium_grid')) ?></a>
                                    </div>
                                <?php } ?>
    							</div>
    
    					<?php } else { ?>
    						<div class="posthometext">
    						<br />
    						<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Link to %s', 'codium_grid'), esc_html(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h2>
    							<div class="entry-content-home">
    							<?php echo substr(get_the_excerpt(), 0,140); ?> [...]
    							</div>
                                <?php if(get_the_title() == ''){ ?>
                                    <div class="entry-content-home">
    							        <a href="<?php the_permalink() ?>" title="<?php printf(__('read this post', 'codium_grid')) ?>" rel="bookmark">&raquo; <?php echo (__('read this post', 'codium_grid')) ?></a>
                                    </div>
                                <?php } ?>
    						</div>
    
    					<?php }?> 
    
    			</div>
    			<!-- End post -->
    			</div>
    
    <?php endwhile; endif ?>
    
    <div class="clear"></div>				
    
    <div class="center">
    	<?php if(function_exists('wp_pagenavi')) {
    		wp_pagenavi();
    	} else {?>
    		<div class="navigation mobileoff"><p><?php posts_nav_link(); ?></p></div>
    		 <?php } ?>
    		<div class="navigation_mobile"><p><?php posts_nav_link(); ?></p></div>
    </div>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php get_sidebar() ?>
    <?php get_footer() ?>
  4. rolzan
    Member
    Posted 5 months ago #

    <?php endwhile; endif ?>
    <?php get_sidebar() ?>
    <?php get_footer() ?>

    is there any difference when putting semi-colons after the codes above? (e.g. get_sidebar();, get_footer();)

    What happens when you remove your category.php file? Making WordPress choose index.php when showing categories.

  5. k00kaine
    Member
    Posted 5 months ago #

    I tried adding the " ; " to the sidebar and footer strings and it didn't seem to make a difference.

    I also FTP'd and renamed the category.php file to categoryBackup.php. Refreshed the page a few and it looks like WP chose the archive.php as the template to show the category's. Unfortunately the archive.php also has this same issue without being able to show the sidebar or even footer as well. that was good test though to see what it defaults too

  6. rolzan
    Member
    Posted 5 months ago #

    by removing archive.php, WordPress defaults to index.php, try removing archive.php or changing its file name, and see if it shows the sidebar and footer, in that way, the posts page and the category page has the same template, then you can determine if there's something wrong with your templates, or if the problem lies in a different area other than the template files.

  7. k00kaine
    Member
    Posted 5 months ago #

    Strange, I've changed the archive.php file as well because thats what it was defaulting to. It defaulted to something, not too sure if it's the default or not because the side bar still didn't show. this is strange

  8. k00kaine
    Member
    Posted 5 months ago #

    actually you know what rolzan, I just re-tried doing the

    <?php get_sidebar() ?> to <?php get_sidebar(); ?> by adding the ";" and that worked. thank you!

  9. henri
    Member
    Theme Author

    Posted 2 months ago #

    So this topic is revolved!

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.