Support » Requests and Feedback » Missing the ability to pass class (or id, or title) to function

  • I build the paging, with the function previous_posts_link and next_posts_links. And oups! Can’t target the to resulting links with css. 2 choices…

    1) Wrap in useless element just for design purpose… Results in poor semantic xhtml.
    2) Make change directly in wp-include/link-templates.php… Realy bad for futur update
    3) Create new function and use it… Result in lot of code duplication and no so better for future update.

    And it’s like that everywhere in WordPress.

    And this bring me to a conclusion… WordPress “choose” for us how to display everything and offer really little flexibility when we goes out of the box. It’s seems evident (probably because I’m used to work with Symfony) that each and every function who output something must accept an additional array parameters for id, class, rel, title…

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think the internet will survive if you put your navigation links in a div.

    First, it’s not only for the paging, each elements generated by WordPress function don’t allow custom attribute for the tag, which is restrictive without any justification.

    Your right: it’s not so bad just for css selection, as we can wrap in other element. Not perfect, but workaround is easy and pretty common on the web.

    But when it’s come to microformats, rel attribute for prev/next links, or title attribute over a link, this lack of flexibility is no more acceptable.

    Inspired of Symfony, I think about something like that:

    previous_post_link('%link', 'Previous post', array(
        'rel'   =>'prev',
        'class' =>'previous')

    While wordpress doesn’t let you specify the class attributes, it does generate them for almost everything. wp_list_pages/categories/bookmarks have class attributes on every element, for example.

    I don’t think it’s necessary to specify them manually – otherwise for wp_list_categories you would have to specify at least 6 classes (or many more if you wanted to be just as specific as it is already)

    A default class is fine… and for functions with only one purpose like previous_post_link (what else does it do?.. right?) you could hard-code the rel attribute as well, no need to specify it as a function parameter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Missing the ability to pass class (or id, or title) to function’ is closed to new replies.