luispunchy
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Link orderI am having the same issue, trying to assign “blogroll” links to appear in a certain order – specifically, by rating, and it doesn’t seem to work.
I am further confused by the fact that the codex docs on Links Manager refers to specific functionality which doesn’t seem to exist in 2.6 (version I’m using)… though I cannot imagine why those options would have been removed as they seem quite logical and useful.
Forum: Fixing WordPress
In reply to: Modify wp_get_archives | highlight current archive categorysigh… anybody? I’ll keep plugging through the source and post back here if I can figure it out, but I’m thinking *somebody* must have tried this before… and got it working… anybody??
Forum: Themes and Templates
In reply to: Modify wp_list_categories tag’s generated markup bloat?Long time, but finally got back to this particular issue and confirmed that the “hack” noted above DOES NOT output the
class="current-cat"
attribute/value pair when rendered on category pages. If that is a desired result (was for me), then this won’t work.I’m far from a php expert, so there’s likely a correct way to get that desired result… if anybody knows, feel free to chime in (ask for clarification if needed, as well). Thanks!
Meanwhile, I decided to “let it go” (not one of my strong points) and settle for “almost” – here’s the revised hack. Starting at line 678 as of version 2.5:
if ( 'list' == $args['style'] ) { $output .= "\t<li"; if ( isset($current_category) && $current_category && ($category->term_id == $current_category) ) $class .= ' current-cat'; elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) ) $class .= ' current-cat-parent'; $output .= ' class="'.$class.'"'; $output .= ">$link\n"; } else { $output .= "\t$link\n"; } return $output; }
This no longer generates the extraneous default class attribute/value pairs for the list items on all non-category pages – you do get an empty class attribute, however (that’s why it’s “almost” but not quite what I was aiming for). The rest of the logic is left as is, so the
class="current-cat"
attribute/value pair will still be rendered on category pages.Forum: Themes and Templates
In reply to: Modify wp_list_categories tag’s generated markup bloat?Took well over an hour, but here’s the KLUDGEY HACK to get rid of that over-bloated markup generated by the wp_list_categories tag and related functions.
The relevant code is in classes.php (under wp-includes).
The original code, starting at line 635:
if ( 'list' == $args['style'] ) { $output .= "\t<li"; $class = 'cat-item cat-item-'.$category->term_id; if ( $current_category && ($category->term_id == $current_category) ) $class .= ' current-cat'; elseif ( $_current_category && ($category->term_id == $_current_category->parent) ) $class .= ' current-cat-parent'; $output .= ' class="'.$class.'"'; $output .= ">$link\n"; } else { $output .= "\t$link<br />\n"; } return $output; }
Updated to following:
if ( 'list' == $args['style'] ) { $output .= "\t<li"; if ( !( $current_category && ($category->term_id == $current_category) ) || !( $_current_category && ($category->term_id == $_current_category->parent) ) ) $output .= ">$link\n"; return $output; } else { if ( $current_category && ($category->term_id == $current_category) ) $class .= ' current-cat'; elseif ( $_current_category && ($category->term_id == $_current_category->parent) ) $class .= ' current-cat-parent'; $output .= ' class="'.$class.'"'; $output .= ">$link\n"; } return $output; }
The end result being that by default, the list items are now generated WITHOUT the unnecessary class attributes. If you are on a Category page, then the ‘selected’ class attribute will be generated for that category’s respective list item.
I have tested on the index page and the markup is good. I’m still building the rest of the theme templates so I have tested whether those class attributes actually *WILL* show up on the category pages… TBD.
Forum: Themes and Templates
In reply to: Modify wp_list_categories tag’s generated markup bloat?talking to myself here ?? But to clarify, what I want ideally is for that wp_list_categories tag to instead just push out much slimmer markup without all the extra class attributes. Such as:
<ul id="categories"> <li><a href="#">Category name</a></li> <li><a href="#">Category name</a></li> ... </ul>
I’m nitpicking here, but I like my code clean and without bloat… it should be that if you need classes or any attributes for that matter, the wp_list_categories tag will allow you to pass it arguments to get what you need in the output. Otherwise, it should just keep to the minimum markup… IMHO.
Still looking for the suspect include template file / code that controls this…
Forum: Themes and Templates
In reply to: Modify wp_list_categories tag’s generated markup bloat?I think I see those extraneous class attributes are being added in classes.php (under wp-includes). I am going to backup and edit that and see what happens…
Meanwhile, a gripe / request / question on this issue:
WHY does WordPress insert those extra class names in the first place? And wouldn’t it be swell if the codex included just a small amount of documentation on how such markup is generated and where to go to edit it?