Don't bother looking for the 'social' buttons to share, save or bookmark this post: Leave your feedback in the comments and get the discussion started!
Like the TDO mini form plugin the AZIndex is an incredible powerful plugin…but also lacks a certain feature, which would make it just perfect: URL’s for the header, the subheaders are grouped by.
AZIndex is just great, but the following mini-hack will make it simply perfect. By adding a simple yet necessary feature: generating an URL for the groupheaders: see http://fan-tas-tic.com/artists/ for a live demo and imagine you can’t click the author names for an example of the original plugin without this lill’ hack.
The general assumption is that the plugin is abandoned by its original author, since there hasn’t been any reaction on the official AZIndex plugin feedback page by the author. So I had to it myself. Again.
The following instructions makes sure a groupheader (tags, author or categy) has an accompanying link (when a subheader is selected).
The most recent version (0.8.1) has been used for this hack, but you should be able to implement it also in older or newer versions following the next steps:
0. Make your backups or try this on a local installation as always with hacks (although I’ve got a nasty habit myself of hacking directly on my live sites
but do as I say, not as I do)
1. Get the original plugin from the WordPress plugin repository.
2a. Either unzip the plugin and edit az-index-content.php
2b. Or upload the unzipped plugin directly and open az-index-content.php via the plugin-editor
3. Apply the following changes:
a. Find around rownumber 172 the following statement:
$link = get_permalink($item['id']);
b. Add the next statements beneath this line:
//aytemir.com: start mini-hack
$groupheader='';
$groupheader=$index->head;
if ($groupheader=='author') {
$groupheader_id=get_userdatabylogin($item['head']);
$groupheader_url=get_bloginfo('url').'/?author='.$groupheader_id->ID;
} elseif ($groupheader=='cats') {
$groupheader_id=get_cat_id($item['head']);
$groupheader_url=get_bloginfo('url').'/?cat='.$groupheader_id;
} elseif ($groupheader=='tags') {
$groupheader_id=$item['head'];
$groupheader_url=get_bloginfo('url').'/?tag='.$groupheader_id;
}
//aytemir.com: end mini-hack
c. The code is self-explanatory, I think: just get the header you want to sort/order by, retieve the accompanying ID and generate an URL and apply URL in case of tag, category or author.
d. Find (around rownumber 203) the following statement:
$output .= '<li'.$charlink.($odd ? ' class="azalt"' : '').'><span class="head">'.$item['head'].$cont.'</span>'.$cr;
e. And replace it with the following statement:
//aytemir.com: start mini-hack
if ($groupheader=='author' || $groupheader=='cats' || $groupheader=='tags') {
$output .= '<li'.$charlink.($odd ? ' class="azalt"' : '').'><span class="head"><a href="'.$groupheader_url.'">'.$item['head'].$cont.'</a></span>'.$cr;
} else {
$output .= '<li'.$charlink.($odd ? ' class="azalt"' : '').'><span class="head">'.$item['head'].$cont.'</span>'.$cr;
}
//aytemir.com: end mini-hack
5. Save and test it (locally) and let me know if it works for you.
Don’t want to bother ‘hacking’ yourself? You could also download the fully zipped version with the hack already implemented:
1. Download this hacked version, which I doped 0.8.2
2. Upload, activate and test the plugin.
For usage and configuration instructions please refer to the original plugin site.
If you should run into issues regarding this specific hack, please let me know in the comments.
How can I embed an image with the post links that are less than (lets say 7 days old) … for instance I would like an image called new.gif to be added to the end of the text of all post links that are less than said days old. Where in the code where I put this function and can you help me create it please. Thanks
You can use the code/tut here: http://wpengineer.com/if-post-is-older-than/
It works like a charm!
Thanks for the referral! I’m not a wp expert and I’m trying to understand how the script works. I have been exhausting myself the last two days trying to get this to work with no luck … can you please help with this hack. Thanks!
OK so after figuring out how to get_post_time to work this is what I came up with? Is this too much? What do you think?
After:
$link = get_permalink($item['id']);
I added:
$days = 14;
$statuss=”;
$days = (int) $days;
$offset = $days*60*60*24;
if ( get_post_time($d=’U',$gmt=false,$post=$item['id'],$translate=false) > date(‘U’) – $offset ){
$statuss = ”;
}elseif ( get_post_modified_time($d=’U',$gmt=false,$post=$item['id'],$translate=false) > date(‘U’) – $offset ){
$statuss = ”;
}else{
$statuss = ”;
}
After that I add/echo $statuss in the output!
Seems to be working!
Looks fine to me, although the original code is more compact.
Thank you! I have been beating my head against the wall for 3 hours trying to code exactly this hack. I couldn’t find a way to output only the current heading’s URL; I kept creating a string of all of them.
At any rate, thanks. I’m using it for an index of categories with posts as subheads.