The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Link to exact comment (7 posts)

  1. dawg
    Posted 10 years ago #

    I have a few different themes and I am not sure what in the comment.php code works to link to the individual comment.

    For example if I want to put a link in an entry pointing to comment #3748 it will work with some of my themes but two themes it will not work to link, it will only link to the entry that has the link, but not the individual comment.

    What code should be added to the comments.php to make it allow it to link to the individual comment?

    I hope this makes sense, it is just some entries have several hundred comments and it is like looking for a needle in a haystack.


  2. Kafkaesqui

    Posted 10 years ago #

    You want to use comment_ID() in combination with some element of each comment that can be assigned the ID attribute. If comments are in list (<li>) elements, you could do:

    <li id="comment-<?php comment_ID(); ?>">

    Then #comment-3748 would become the fragment identifier for that comment. (#3748 would be considered invalid XHTML, as fragment idents cannot start with a number.)

  3. dawg
    Posted 10 years ago #

    Thanks Kaf

    <li id="comment-<?php comment_ID() ?>">

    The above is what I had that worked in the themes that did link correctly.

    I added the code, you will notice I am missing the semi-colon ; but both work. Question is I know have a bullet outside the comment area that was not there before?

    any ideas?


  4. Kafkaesqui

    Posted 10 years ago #

    The semicolon is used to define the end of a PHP statement. In most operating environments a single PHP statement within <?php ?> tags can be used without having to close it with a semicolon.

    I can suggest how to remove the bullets through your css, but as you didn't originally have comments in <li> elements, you might want to remove them and instead go with altering your commentid div:

    <div class="commentid" id="comment-<?php comment_ID(); ?>">

  5. dawg
    Posted 10 years ago #

    I tried that, it worked and got rid of the bullets but the text was all <h1>and large, I opted for putting the bullets back in,

    Thanks lets try the css route.

  6. Kafkaesqui

    Posted 10 years ago #

    Just add this to your stylesheet:

    #content li {
    list-style: none;

    Notes: <li> tags must be nested in a <ul> or <ol> element to be valid X/HTML. Also, without being able to define the comments section for this, all <li> tags under the content div will be affected by the css declaration above, but you can *fix* this by defining an id for your <ul> or <ol> element (let's say "comments") and using for your declaration:

    #comments li {
    list-style: none;

  7. dawg
    Posted 10 years ago #

    Thanks Kaf, that worked, I guess I was just brain dead this afternoon.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.