• Resolved ankatank

    (@ankatank)


    when you click a category page on my site (here’s one: http://ankatankdesign.com/makes/some/print/ )

    it displays stuff based on whats in my “sidebar-right.php”

    when you click a tag, (for example: http://ankatankdesign.com/makes/tag/film/) i’ve got it set up to do the exact same thing, but it doesn’t give me anything. I’ve tried to modify the sidebar-right.php code to inlcude tag code, but I keep breaking it, so i’ve removed it, hoping someone can tell me what I need to do to make it work. (i do not know php well, just what i am learning from creating this wordpress site…)

    this is the code in my category.php:

    <?php get_header() ?>
    <?php get_sidebar('right'); ?>
    <?php get_footer() ?>

    this is the code in my tag.php:

    <?php get_header() ?>
    <?php get_sidebar('right'); ?>
    <?php single_tag_title(' tagged ' , 'true' ); ?>
    <?php get_footer() ?>

    here’s the code in my sidebar-right.php:

    <div id="secondary" class="sidebar-CAT">
    
    		<?php $cat_title = single_cat_title('',false);
                if (!$cat_title=='') {
    
                if ( !empty($categorydesc) ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . $categorydesc . '</div>' );
                    }
             ?> 
    
    		<?php  
    
            if(is_single()) {
    
                $category = get_the_category();
    
    			query_posts('posts_per_page=-1&category_name=' . $category[0]->cat_name);
    
            } else {
    
                query_posts('posts_per_page=-1&category_name=' . single_cat_title(false, false));
    
            }
    
            while (have_posts()) : the_post(); ?>
    
           		<div id="sidebarCAT"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="http://www.aaank.com/images/post_thumbs/<?php $values = get_post_custom_values("theThumb"); echo $values[0]; ?>" alt="" /></a>
    
                <!--<div class="underThumb">< ?php the_date('m d Y', '', ''); ?></div>-->
                <div class="underThumbTxt"><?php if (strlen($post->post_title) > 15) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 15) . '...'; } else {
    the_title();
    } ?></div>
    
               </div>
    
    		<?php endwhile; wp_reset_query(); ?>
    
           	<br style='clear:both;' />	
    
    </div>

    can anyone tell me how i should to modify the sidebar-right.php code so that if a tag is clicked, it shows, tags results just like it shows category results? (i realize that there will no longer be a selected nav item, and i’m ok with that.)

    thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ankatank

    (@ankatank)

    nevermind, got it to work!

    in case this is of help to anyone else, this is what i ended up doing.

    in my tag.php file, instead of including code that gets the sidebar-right.php, ( <?php get_sidebar(‘right’); ?> ) i deleted that, and copied the code from that file into tag.php, then replaced the category-specific stuff with tag-specific stuff:

    <?php get_header() ?>
    < ?php single_tag_title(' tagged ' , 'true' ); ?>
    
        <div id="secondary" class="sidebar-CAT">
    
    		<?php $tag = single_tag_title('',false);
                if (!$tag=='') {
    
                if ( !empty($tagdesc) ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . $tagdesc . '</div>' );
                    }
             ?> 
    
    		<?php  
    
            if(is_single()) {
    
                $tag = get_the_tags();
    
    			query_posts('posts_per_page=-1&tag=' . $tag[0]->cat_name);
    
            } else {
    
                query_posts('posts_per_page=-1&tag=' . single_tag_title(false, false));
    
            }
    
            while (have_posts()) : the_post(); ?>
    
           		<div id="sidebarCAT"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="http://www.aaank.com/images/post_thumbs/<?php $values = get_post_custom_values("theThumb"); echo $values[0]; ?>" alt="" /></a>
    
                <!--<div class="underThumb">< ?php the_date('m d Y', '', ''); ?></div>-->
                <div class="underThumbTxt"><?php if (strlen($post->post_title) > 15) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 15) . '...'; } else {
    the_title();
    } ?></div>
    
               </div>
    
    		<?php endwhile; wp_reset_query(); ?>
    
           	<br style='clear:both;' />	
    
    </div>
    
    <?php get_footer() ?>

    Also might want to simply add this to the sidebar.php page around line 30.

    <?php if ( is_404() || is_category() || is_day() || is_month() ||
    is_year() || is_search() || is_paged() || is_tag() ) {?>

    I am referring specifically to the || is_tag()

    then around line 50 add:

    <?php /* If this is a tag archive */ } elseif (is_tag()) { ?>
    <p>You are currently browsing posts tagged <?php single_tag_title(''); ?></p>

    This should allow a user to click on a tag in a single or multi entry page and have the sidebar update with the current tag being viewed just like categories, search and archives work.

    Thread Starter ankatank

    (@ankatank)

    Hey thanks! Sorry for the late response, I only just saw this! That will really improve the site functionality so I am definitely going to try that out. Thanks so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘need the tag page to act/display just like the category page….’ is closed to new replies.