• I’ve searched and searched and am wondering if something like the following exists for tweaking the display on comment “numbers”. I’d just like to display the comments completely numerically but zero pad the output to a fixed position. So when there are 7, 21, or 100 comments it would instead display it as 0007, 0021, 0100 respectively.

    Anyone know of a good plugin or method to help me along in my quest?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You should be able to use CSS to do that. Find the <ol> wrapper in your comments.php template and change it to <ol style="list-style-type:decimal-leading-zero;">

    See how that works out for you.

    Thread Starter vlogtheimpaler

    (@vlogtheimpaler)

    I’m actually using list-style-type: none; to to drop numerals and bullet points across the board. In addition I’d like to be able to pull data before and after without having to resort to further CSS headaches while styling the padded zero portion different from the actual number. First I’d just like to get those leading zeros in there via PHP with a plugin if at all possible.

    Thread Starter vlogtheimpaler

    (@vlogtheimpaler)

    Ideas anyone? Nathan?

    Vlog,
    I stumbled upon this post while trying to find the same solution.
    Not sure if you found your answer but I was able to come up with a solution that worked for me. I was looking to pad the comment number, so that it was always 3 digits, in a link that was being generated by the function

    comments_popup_link('000', '001', '%');

    What I did was rather than use this function I dissected how it was getting all it’s bits and replaced the instance of the function call with the following code.

    echo '<a href="'.get_permalink().'#comments" title="Comment on '.get_the_title().'">';
    printf ("%03d", get_comments_number());
    echo '</a>';

    It’s not exactly the most elegant thing but it does what I want it to. Hope that’s helpful.

    J.

    jthomasc – this worked perfectly.

    thank you.

    jthomasc,

    one problem – this code doesn’t give you the option to do something like this:

    comments_popup_link('add', '1', '%');

    While where the % gets the leading zeros but ‘add’ is still an option for no comments. Any way to accomplish this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Zero padding numeric comment numbers’ is closed to new replies.