The development of WordPress topic – the comment list expands and expands to show sub comments

This article records a list of WordPress reviews you’ve been fooling around recently

The picture is small and fast. If you look at it carefully, you will find that the sub comment is controlled by clicking the View dialog button. At the same time, the View dialog and close dialog also change with the scaling.

Does it look interesting?

No more nonsense. I post the code and talk about the implementation process

The first thing to control is to view and close the dialogue. It only appears in parent comments with child comments. My idea is to judge $comment – >comment first_ Whether parent is 0 or not; at the same time, in the day before yesterday’s toss, there is a function to record the number of sub comments, which is controlled by child_ comment_ counter($comment->comment_ ID) is greater than 0. The code is as follows:

<?php if(child_comment_counter($comment->comment_ID)>0 && $comment->comment_parent == '0'){?>  
<div class="part js-comments">  
<i class="icon-message"></i><span class="js-comment">查看对话</span>  
<?php }?>  

Then to control the View dialog button, click to display sub comments for the first time, and modify the View dialog to close the dialog. Click the second time to close the sub comment and change the closed dialogue to view the dialogue:

$(".part .js-comment").click(function(){  

It should be noted that by default, ul.children Display: none.

Just the sauce. It seems that the theme of a tiger sniffing moustache imitates my effect. If you want to see it, you can go to his website to find a demonstration station.

Related Article
WordPress displays the registration time of the login user in the frontend

When using WordPress to build a website, some users want to display the user registration time in the frontend, but Read more

WordPress adds the number of SQL queries at the bottom

An excellent woodpress theme is definitely that the less SQL consulting is used, the better. How can we see how Read more

Some WordPress articles can be seen after comments / replies

If we want to hide part of the content of the article and need the user's comments and replies to Read more

WordPress common template function reference document

Basic template filefile namedescribe style.css Theme style file index.php Home page template file header.php Header template file single.php Single article Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image