• Alex Cragg

    (@epicalex)


    i recently altered my comments.php to highlight alternate posts different colours, and also when i wrote a comment, to highlight that a different colour too. I used some code i found in the support forum for the alternate highlighting, and the Author Highlight plugin for highlighting my comments.

    to achieve this, i gave the li tag a class and an id, i created the li class and id like this
    <li class="<?php echo $oddcomment; ?>" id="<?php author_highlight(); ?>">

    where the $oddcomment variables had been defined before.

    what i now want to know is, is it possible to create a plugin that would define the class and the id of the li tag in one go, as opposed to two sections.
    so you’d end up with something like this
    <li <?php admin_alt_highlight(); ?>
    which would create an output like
    <li class="alt" id="author">

    any pointers much appreciated

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Alex Cragg

    (@epicalex)

    anyone know if this sort of stuff is possible?

    You need to keep in mind that in CSS and “id” attribute must be unique, so this is actually invalid, unless there’s only one comment made by the author:

    <li class="alt" id="author">

    I’m assuming from what you’re saying that you want to be able to somehow highlight any comments by the author of the post. If so, the above is only good if the author leaves only one comment, which is impractical.

    Perhaps a better solutions is to use multiple classes (instead of a class and an id) instead.

    Thread Starter Alex Cragg

    (@epicalex)

    @pizdin_dim – i realized that after i posted this topic(thanks to the validator), and i changed it straight away on my current theme.

    mod look added for jmcpherson421 posts…pretty weird posts IMO.

    so im not really any closer…

    ill phrase it differently,

    i would like to know how to generate 2 class out puts in 1 php call.

    Instead of <li class="alt" id="author"> use <li class="alt author">

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Define class and id using php’ is closed to new replies.