• Hi,

    I run a music website, which has articles on over a 100 different bands and each article is tagged with the bands name.

    For the last couple of weeks I’ve been trying to create an index of the bands using the tags. So far I can only get all the tags on one page split into columns, which can be seen here http://www.addictmusic.co.uk/a-z/

    What I ideally want is to have a multi-page index, which will group the pages alphabetically, with an alphabetical navbar at the top.

    So all tags under A would be on one page and all tags under B on the next and so on.

    I have tried the A-Z index plugin, but it doesn’t split the pages by letter or use the tags properly

    If anyone can help I would be very grateful

    Thanks

Viewing 15 replies - 16 through 30 (of 67 total)
  • http://x-files.net.ua/?page_id=1266

    2) when click (fo example) on letter E – we don’t get a page with only E-tags.
    http://x-files.net.ua/?page_id=1266?tags=e – not only E, but all tags.

    3) the list of tags is not exluding what i need to exclude. is it possible to exclude?
    i’m using a http://wordpress.org/extend/plugins/template-tag-shortcodes/ plugin with this code:
    [wp_tag_cloud smallest=8 largest=10 number=10000 order=ASC exclude=16,58,59,60,61,62,63,64,65,66,67,68,69,70,72,71,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,90,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,213,354,355,380,381]
    .

    You should ask the author for support if you need help using a particular plugin (or seek out the authors documentation, if there is any).

    I can’t advise you on software i don’t use (although i could guess, it may not be helpful). You’re welcome to try the code i posted, and i’ll happily help you with that, because i can see and know all the associated code.

    well, if you’ll get smth on your mind about my problem, that whould be great to have some advise from you.

    about author of code: i look through http://wordpress.pastebin.ca/1730939 and just can’t get how to contact to author… would you please point me?..

    I wrote the code in the pastebin.. 😉 It’s for use as a page template.

    You mentioned the template tag shortcodes plugin before, so i assumed you were wanting to use that alongside or instead of the pastebin code.

    If you’re using the code i supplied (in the pastebin), are you saying there’s a problem with incorrect tags showing up using it “as is”? Or are you trying to use this code “inside / alongside / in conjunction with” the aforementioned plugin?

    well, step by step my actions:
    1) created a file azindex.php and placed it into /themes/simple-notepad/ with CHMOD 777

    2) in admin panel Theme editor (/wp-admin/theme-editor.php?file=/themes/simple-notepad/azindex.php&theme=Simple+Notepad) i added your code to azindex.php:

    <?php
    /*
    Template Name: Tag Index
    */
    
    get_header();
    
    $valid_characters = range( 'a' , 'z' );
    $valid_numbers = array(1,2,3,4,5,6,7,8,9,0);
    
    $nav = array();
    // Build nav array
    foreach( $valid_characters as $key => $character )
    	$nav[] = '<a href="' . get_permalink( $post->ID ) . '?tags=' . $character . '">' . strtoupper( $character ) . '</a>';
    foreach( $valid_numbers as $key => $number )
    	$nav[] = '<a href="' . get_permalink( $post->ID ) . '?tags=' . $number . '">' . $number . '</a>';
    
    // Array to hold tags, needs to be set, so the empty check works when none of the switch cases hit a match (for whatever reason)
    $tags = array();
    // Array that will hold arrays of tags based on their first letter
    $tag_array = array();
    
    // Main switch
    switch( true ) {
    	// If request for tag with particular letter
    	case ( isset( $_GET['tags'] ) ):
    		// If it's in the arrays created earlier, get tafs and sort into array
    		case ( in_array( $_GET['tags'] , $valid_characters ) || in_array( $_GET['tags'] , $valid_numbers ) ):
    			$tags = get_terms( 'post_tag' , "hide_empty=0&name__like=$_GET[tags]" );
    
    			if( !empty( $tags ) ) {
    				foreach( $tags as $tag ) {
    					$tag_array[$tag->name{0}][] = '<li><a href="'.get_tag_link( $tag->term_id ).'">'.$tag->name.'</a></li>';
    				}
    			}
    		break;
    	break;
    	case ( !isset( $_GET['tags'] ) ):
    	default:
    		$tags = get_terms( 'post_tag' , 'hide_empty=0' );
    
    		if( !empty( $tags ) ) {
    			foreach( $tags as $tag ) {
    				$tag_array[$tag->name{0}][] = '<li><a href="'.get_tag_link( $tag->term_id ).'">'.$tag->name.'</a></li>';
    			}
    		}
    	break;
    }
    // If theres only one item in the array ( well one key ) , then it's a requested tag letter, so add a "Show all" link at the start of the nav
    if( count( $tag_array ) == 1 ) array_unshift( $nav , '<a href="' . get_permalink( $post->ID ) . '">Show all</a>' );
    ?>
    
    <div id="content" class="widecolumn">
    	<!-- Feel free to add regular stuff you want here, like the_content() etc. -->
    	<div class="nav">
    		<?php
    			// Imploding an array is an easy and reliable way to create a string with seperators
    			echo implode( ' | ' , $nav );
    		?>
    	</div>
    <?php
    	// If there's tags in the array
    	if( !empty( $tag_array ) ) {
    		foreach( $tag_array as $character => $character_tags ) {
    		?>
    			<div class="tagindex">
    				<h4><?php echo $character; ?></h4>
    				<ul class="links">
    					<?php foreach( $character_tags as $key => $tag ) { echo $tag; } ?>
    				</ul>
    			</div>
    		<?php
    		}
    	}
    	else {
    		?>
    		<h4>No tags found</h4>
    		<?php
    	}
    	?>
    </div>
    </div>
    <?php get_footer(); ?>

    3) added a new page (/wp-admin/page-new.php) with empty textarea.
    on the right side i choose Tag Index for template.

    4) finaly, we have http://x-files.net.ua/?page_id=1266

    —-
    problem:
    clicking on any letter, we will get to page where will be all the tags, not what we choose.

    P.s.

    Perhaps you have something else interacting with the page…

    I’ve just taken the code straight from your post above, created a file using the same process as you’ve laid out above.

    Page loads appropriate tags for me..

    Can you “test” under the default theme?

    the same thing with default theme. 🙁
    i can give you the full access to my blog if you wish, so you could look through what is wrong.

    Please, very need your code to be working 🙂

    Maybe there’s a problem with one of the functions i referenced.

    Are you on PHP4 by any chance?..

    If no, then i’d suggest toggling plugins to see if that has an effect (ie. turn off, test page, if no change re-enable, and so on for each).

    PHP5 the latest.
    about turning off plugins – will try.

    P.S. again:

    i can give you the full access to my blog if you wish, so you could look through what is wrong.

    Please, very need your code to be working 🙂

    well, I deactivated all my active (21) plugins.
    waited a little bit, cleared a cache in browser, got to http://x-files.net.ua/?page_id=1266 , clicked on letter P (and any other).
    and no result, http://x-files.net.ua/?page_id=1266?tags=p – shows all tags, not only started with letter P.
    🙁

    Ok email me some login credentials and i’ll take a look for you…

    [moderated]

    Excuse the name, it’s where spam goes. Since i’m posting it openly (where the spammers can see it) i’d prefer to use it… 😉

    i send an e-mail to [moderated]

    Just going to take a look now..

    EDIT: Spotted the error, will be corrected shortly.. 😉

    EDIT2: All done, have emailed you, incase you’re not monitoring the thread.

    Problem was i hadn’t accounted for default permalinks (silly mistake)..

    For clarity, the fix for above.
    http://wordpress.pastebin.ca/1746118

    THANK YOU!!!!!!!!!!!!!!

    and about second problem – is it possible to get an exclision in your code for some tags by id? it’s very important for me to make exclusions there, so it wouldn’t show some tags.. 🙂

    P.S.wouldn’t it be difficult to you if i’ll ask for some template-editing help?

    P.P.S. i alwaya monitor threads a lot of time per day 🙂 🙂

Viewing 15 replies - 16 through 30 (of 67 total)
  • The topic ‘How to have an multipage alphabetical Tag index’ is closed to new replies.