• Hi – I have a wordpress site with 900+ pages on different topics, each with a “comments reply form.” My issue is with that many possible comments and replies, the page with the “comments list” will grow long and the threads won’t be organized for clarity – I need it to be “nested.”

    I’ve been all over Google but haven’t found a solution that works – even got in a fight with someone on Stack Overflow over it so left quickly. Found a stand alone plugin for a beautiful looking comments list but after installing it found it wasn’t nested – when I asked why they said because it was “free.” Why not build a full plugin and then charge for it being premium – I would pay for it.

    I don’t want to install a new “full plugin” with both it’s own nested comments list and paired reply forms – remember I have 900+ pages and don’t want to replace the reply form on all of them any time soon.

    So please help me by pointing me to, or suggesting a solution that will work.

    TIA

    • This topic was modified 11 months, 3 weeks ago by meesha.
    • This topic was modified 11 months, 3 weeks ago by meesha.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Sure, I can help you understand how to create nested comment lists in various programming languages or markup languages. The approach may vary depending on the context, but I’ll provide examples in a few common scenarios.1. HTML and CSS:

    HTML:

    htmlCopy code

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Nested Comments</title> <link rel="stylesheet" href="styles.css"> </head> <body> <ul class="comment-list"> <li>Comment 1 <ul> <li>Reply 1.1</li> <li>Reply 1.2</li> </ul> </li> <li>Comment 2</li> <li>Comment 3 <ul> <li>Reply 3.1 <ul> <li>Reply 3.1.1</li> </ul> </li> </ul> </li> </ul> </body> </html>

    CSS (styles.css):

    cssCopy code

    .comment-list { list-style-type: none; } .comment-list li { margin-bottom: 10px; } .comment-list ul { margin-left: 20px; } 2. Python (using nested lists):

    pythonCopy code

    comments = [ {"text": "Comment 1", "replies": [ {"text": "Reply 1.1"}, {"text": "Reply 1.2"} ]}, {"text": "Comment 2"}, {"text": "Comment 3", "replies": [ {"text": "Reply 3.1", "replies": [ {"text": "Reply 3.1.1"} ]} ]} ] def print_comments(comments, indent=0): for comment in comments: print(" " * indent + comment["text"]) if "replies" in comment: print_comments(comment["replies"], indent + 1) print_comments(comments)

    These are just examples, and you can adapt them based on your specific requirements and the programming language you’re working with. The key is to represent the nested structure in a way that makes sense for the language or context you’re working in.

    I am created this list on this website you can see here https://pcgameshighlycompressed.com/gta-india-download-for-pc/

    Thread Starter meesha

    (@meesha)

    Thanks for the reply and offer to help – I’m working in PhP in a WordPress environment – my experience with PhP goes back 20 years when I learned it to build a website – have not used it since.

    I have over 50 years programming experience but only one in PhP and nothing in Python so that part of your code is a mystery to me.

    I had ChatGPT write a routine but it is only the html structure and does not connect to my database comments – that’s the part I’m having issues with.

    Here is the routine I’m starting with:

    <?php
    
    function generateNestedCommentsList($comments, $parent_id = null) {
        echo '<ul>';
        
        foreach ($comments as $comment) {
            if ($comment['parent_id'] == $parent_id) {
                echo '<li>';
                echo $comment['text'];
    
                // Recursively call the function for nested comments
                generateNestedCommentsList($comments, $comment['id']);
    
                echo '</li>';
            }
        }
    
        echo '</ul>';
    }
    
    // Example usage:
    $comments = array(
        array('id' => 1, 'parent_id' => null, 'text' => 'Comment 1'),
        array('id' => 2, 'parent_id' => 1, 'text' => 'Reply to Comment 1'),
        array('id' => 3, 'parent_id' => null, 'text' => 'Comment 2'),
        array('id' => 4, 'parent_id' => 2, 'text' => 'Reply to Reply 1'),
        // Add more comments as needed
    );
    
    generateNestedCommentsList($comments);
    ?>
    
    The structure works well, so any help will be appreciated - Thanks again.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Nesting Comments List’ is closed to new replies.