• Resolved ternef4339

    (@ternef4339)


    I have activated the Automattic Widgets and when I validate my blog at W3C I got following error message:
    ——————————————————-
    1. Error Line 481 column 8: ID “links” already defined.
    <li id=”links” class=”widget widget_links”><h2 class=”widgettitle”>www</h2>

    An “id” is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).

    2. Info Line 472 column 8: ID “links” first defined here.
    <li id=”links” class=”widget widget_links”><h2 class=”widgettitle”>Forum & N
    ——————————————————–
    The Widget doesn’t work with categories for links and I have tried to find some tip when I search for my problem here on the support forum. But I didn’t find some answer. Is it anyone here who has an idea of solution?

    https://www.utmattningsdepression.net/bloggsida/index.php?cat=3

Viewing 15 replies - 1 through 15 (of 15 total)
  • look in the widget php file and find the part that has id=”links”, and change it to class=”links” wherever it occurs. Classes can be defined more than once.

    now change your css from #links to .links

    Thread Starter ternef4339

    (@ternef4339)

    Oh, I forget to say that I have looked in the widget.php file but I can’t find id=”links” there.

    Thread Starter ternef4339

    (@ternef4339)

    I find the solution by myself. I changed line 47 in the widgets.php file

    from

    ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,

    to

    ‘before_widget’ => ‘<li class=”%1$s” >’,

    and it has been w3c valid in XHTML.

    That fix removes the very useful ID attribute for all widgets!

    An even better fix is to add this line before 362:
    $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);

    This lets wp_list_bookmarks do it’s thing. You end up with links, as before widgets, like “linkcat-16”.

    Ciao!

    Hi !
    Thanks for this very usefull tip !
    I just here to update it :

    • – On wordpress 2.2.1 you have to add :
      $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
      before line 397 (after the } else { )
    • – there are 2 “widgets.php” files, the one we are talking about is : wordpress/wp-includes/widgets.php

    It seems in WordPress 2.3 this value is still not solved and needs manual adjustment:

    By commenting out line 402 in wp-includes/widget.php the original ID and class arguments from wp_list_bookmarks is used. After, the XHTML Validation is correct again!

    BR
    Stefan

    I found this post today as I was trying to validate the xhtml code in my WordPress site.

    I read through the chain of comments, it looks like one of the last two solutions for editing the widgets.php should solve the problem of having unique id’s when using categories in the blogroll.

    I tried commenting out line 402, and that didn’t seem to change anything, and I also tried to add the line of code listed above inside the closing else tag, but that didn’t seem to work.

    Is there something else I can do to get my validation working for this aspect? Has anyone else commented out line 402 and had the blogroll widget use unique id tags?

    Commenting out line 402 did end up working…my page does validate now. I don’t know what I ended up changing by commenting this line out, but it worked for this purpose.

    Yesterday when it didn’t work, I realized my lines were off because I had added the other line in above in the else function. When I looked at it again today, I realized I needed to comment out the line that looks like this;

    'category_before' => $before_widget, 'category_after' => $after_widget,

    I just want to add that the “commenting out line 402-solution” works perfectly. I guess the wordpress theme should remove that line in the next version.

    This is still an issue as of 2.5-RC2 hmmm…

    Yep, would be nice to have this little issue taken care of.

    wordpress 2.5, bug still in :/

    In WP 2.5 the bug’s still there.. I used the “commenting out Line 402” method:

    'category_before' => $before_widget, 'category_after' => $after_widget,

    but this time it’s not Line 402, but Line 433.

    Thanks cyelz, the fix works. ??

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Sigh. I reported this 11 months ago and it still didn’t get into 2.5. Annoying, that is.

    https://trac.www.ads-software.com/ticket/4287

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Widgets – don’t validate links in xhtml’ is closed to new replies.