• Here’s my situation.

    I have tried to make my comments page such that a user can enter his website into the form and a link will be displayed together with his comment.

    However, it is just not working. The ‘link’ turns out to be the address of the comment page itself. I had used the variable $comment_author_url to do this and made it so that <a href="<?php comment_author_url>" target=_blank>Link</a> is displayed.

    It just didn’t work. Out of sheer frustration, I have taken it out.

    Yes, I’m a big fat noob >_< where did I go wrong?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Try <?php comment_author_link() ?>

    Thread Starter leyen

    (@leyen)

    A small typo error in my post, what I meant to say is that I used <?php comment_author_link(); ?>

    Thread Starter leyen

    (@leyen)

    Here’s more info on my problem. My site address is http://www.jonling.com

    My comment page is a popup and the following is my code:
    <?php
    /* Don't remove these lines. */
    add_filter('comment_text', 'popuplinks');
    foreach ($posts as $post) { start_wp();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title><?php echo get_settings('blogname'); ?> - Comments on <?php the_title(); ?></title>

    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
    <style type="text/css" media="screen">
    @import url( <?php bloginfo('stylesheet_url'); ?> );
    body { margin: 3px; }

    textarea { font-size : 9px ;
    font-family : verdana ;
    color : #CCCCCC;
    border : 1px solid #666666 ;
    background-color : #000000; }

    input { font-size : 9px ;
    font-family: verdana ;
    color : #CCCCCC;
    border : 1px solid #666666 ;
    background-color : #000000 ; }
    </style>

    </head>
    <body id="commentspopup">

    <h2 id="comments">Comments</h2>

    <?php
    // this line is WordPress' motor, do not delete it.
    $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    $comment_author_link = (isset($_COOKIE['comment_author_link_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_link_'. COOKIEHASH]) : '';
    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
    $commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
    if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
    echo(get_the_password_form());
    } else { ?>

    <?php if ($comments) { ?>
    <ol id="commentlist">
    <?php foreach ($comments as $comment) { ?>
    <li id="comment-<?php comment_ID() ?>">
    <?php comment_text() ?>
    <p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> by <a href="<?php comment_author_link() ?>" target=_blank><?php comment_author() ?></a> — <?php comment_date() ?> @ <?php comment_time() ?></cite></p>
    </li>

    <?php } // end for each comment ?>
    </ol>
    <?php } else { // this is displayed if there are no comments so far ?>
    <p>No comments yet.</p>
    <?php } ?>

    <?php if ('open' == $commentstatus->comment_status) { ?>
    <h2>Leave a comment</h2>

    <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    <p>
    <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
    <label for="author">Name</label>
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($_SERVER["REQUEST_URI"]); ?>" />
    </p>

    <p>
    <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
    <label for="email">E-mail</label>
    </p>

    <p>
    <input type="text" name="link" id="link" value="<?php echo $comment_author_link; ?>" size="28" tabindex="3" />
    <label for="url"><acronym title="Uniform Resource Identifier">URL</acronym></label>
    </p>

    <p>
    <label for="comment">Your Comment</label>
    <br />
    <textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
    </p>

    <p>
    <input name="submit" type="submit" tabindex="5" value="Say It!" />
    </p>
    <?php do_action('comment_form', $post->ID); ?>
    </form>
    <?php } else { // comments are closed ?>
    <p>Sorry, the comment form is closed at this time.</p>
    <?php }
    } // end password check
    ?>

    <div><strong><a href="javascript:window.close()">Close this window.</a></strong></div>

    <?php // if you delete this the sky will fall on your head
    }
    ?>

    <!-- // this is just the end of the motor - don't touch that line either :) -->
    <script type="text/javascript">
    <!--
    document.onkeypress = function esc(e) {
    if(typeof(e) == "undefined") { e=event; }
    if (e.keyCode == 27) { self.close(); }
    }
    // -->
    </script>
    </body>
    </html>

    I think the problem could be that you’re putting the template tag in an anchor tag. You don’t need to do that.

    Thread Starter leyen

    (@leyen)

    Sorry, I’m a big noob at this. I don’t get what an anchor tag is.

    a user can enter his website into the form and a link will be displayed together with his comment.

    Isn’t that how WP works out of the box? If the commenter enters his website’s URL, his name will be a link to that site.

    Thread Starter leyen

    (@leyen)

    I’ve tried the default format for the comment popup page, and it didn’t work

    An anchor tag is the <a href=... that creates links.

    Thread Starter leyen

    (@leyen)

    Alrighty, took out the anchor tag. Now it repeats the author name twice.

    I also realise that the <?php comment_author_link() ?> tag has the same value as the author’s name

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Url (link) in comments not working’ is closed to new replies.