Support » Themes and Templates » comments link class

  • Anonymous

    I’m new to WordPress and haven’t a clue when it comes to PHP (bar copying and pasting scripts), so I’m a bit confused in all of this, meaning you’ll have to forgive the probably stupid question I’m about to ask. (I did look it up in the forums and on Google and on your Templates page, but I was still clueless at the end.)
    I basically want to change the class of the comments link. Like I said, my PHP skills are rather non-existent so every way I’ve tried it so far has just come up with errors.
    Again, sorry if this is a really stupid question or if it’s already been addressed. Thanks & take care anyway. 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • Mark (podz)


    Support Maven

    To change the colour, font, size, hover behaviour, it’s all css:
    /* The Comments link */
    .feedback {
    font: 90%/175% Verdana, Tahoma, sans-serif;
    letter-spacing: -1px;
    color: #ccc;
    text-align: right;
    clear: both;
    .feedback a {
    color: #ccc;
    text-align: right;
    clear: both;
    .feedback a:hover {
    color: #ff0000;
    text-decoration: underline overline;

    I found there were problems attaching classes to functions like edit_comment_link and edit_post_link.

    Here’s what I did:
    I went into wp-includes and opened templates-functions-links.php

    I changed the 2 functions to the following:

    function edit_post_link($link = ‘Edit This’, $before = ”, $after = ”, $CSSclass=”) {
    global $user_ID, $post;


    if (!user_can_edit_post($user_ID, $post->ID)) {

    $location = get_settings(‘siteurl’) . “/wp-admin/post.php?action=edit&post=$post->ID”;
    echo “$before <a href=\”$location\””;
    if(!empty($CSSclass)) {
    echo ” class=\”” .$CSSclass.”\””;
    echo “>$link $after”;

    function edit_comment_link($link = ‘Edit This’, $before = ”, $after = ”, $CSSclass=”) {
    global $user_ID, $post, $comment;


    if (!user_can_edit_post_comments($user_ID, $post->ID)) {

    $location = get_settings(‘siteurl’) . “/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID”;
    echo “$before <a href=’$location'”;
    if(!empty($CSSclass)) {
    echo ” class=\”” . $CSSclass. “\””;
    echo “>$link $after”;

    Then I could add the class when I made the function call. Example:
    <?php edit_comment_link(‘edit’,”,”,’white’); ?>

    I’m new to wordpress, too, so if there is a better way to do this that I don’t know about, let me know. I didn’t see anything in my search.

    I’m confused by your question. The CSS style “class” doesn’t go inside of the code but is assigned to the HTML that structures the code. For example:

    <div class="comments"><?php blah blah code ?>.....</div>

    I’m not sure why you are pushing style classes into the code. They are already there. You need to go to the style.css that comes with the Themes that you have chosen and edit it as podz explained.

    Is there a specific reason you want the CSS classes done the way you have listed?

    Those functions return something like this:

    <A href=”…”>text</A>

    Wrapping a DIV around the above and assigning a class to it does not apply the class to the text within the <A> tag.

    You need to assign the class directly to the <A> tag. The modifications I made to the functions accomplishes that.

    No, wrapping a DIV around the above doesn’t apply the class to the text, but that doesn’t change the fact that you can create a selector using that div to apply a style to the tag.

    .comments a {
    styles go here.

    Yes, but I’m using the style sheet from my already existing website. Instead of adding code to the style sheet and adding the div tag each time I use these functions, I can just add the parameter to call the class I’ve already created.

    IMO, my solution is more efficient.

    The way you stated it implied that the only way to apply a style to a link in any way was by making the link have a class and WP allows no way to do this, hence the “need” for your modification to the core functionality. Admittedly, if you’re trying to fit your existing stylesheet into WordPress without modifiying the stylesheet, what you say is true, but in terms of the seemingly accepted WordPress way surrounding the link with a styleable div or span it was not true.

    Of course, your answer directly addressed the original poster’s actual question so it’s all good anyway.

    Sorry for the confusion. I should have explained my particular situation from the beginning.

    I tried forcing the style sheet from WordPress Themes into my own by changing the tags on the php pages instead of the stylesheet. DUMB. I knocked my head against the wall for over a week trying to hunt down all the styles within the code and renaming them. The modular thing is great, but I just couldn’t force my design upon them.

    So I figured out I was doing something dumb, even after all that work, created a new theme from a theme template I liked and then changed my stylesheet to match the stuff inside WordPress.

    1. It makes switching Themes easier (if I ever choose to do again)
    2. When asking and answering questions in the forums, the CSS references match what is being discussed.
    3. It’s actually less strain on my mental capabilities because I don’t have to risk slipping with the php code and CSS if much easier to fix.
    4. The stylesheets created by the developers and a few theme designers (not all cuz many are still learning) are really tight, already MSIE debugged and Firefox friendly, as well as a few other browser having been tested, so there is MUCH less I have to do to avoid stumbling over these bugs.

    For me, those were the main reasons, along with a few others but these are most important.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘comments link class’ is closed to new replies.