wordpress - display comments on different categories -
I want to display a comment on one of the categories on my WordPress site, for example, for example my peer A comment function will be available on posts in the category, but the comment section on my orange page will be disabled.
Any suggestions?
content.php
file change:
& lt ;? Php if (comments_open ()):? & Gt; & Lt; Div class = "comments-link" & gt; & Lt ;? Php comments_popup_link ('& lt; span class = "leave-reply" & gt;' __ ('Leave a reply', '20th'). '& Lt; / span & gt;', __ ('1 answer', 'Twentieth times'), __ ('% answers', 'twentieth')); ? & Gt; & Lt; / Div & gt; & Lt ;! - .comments-link - & gt; & Lt ;? Php endif; // comments_open ()? & Gt;
to
& lt ;? Php $ postid = get_the_ID (); $ Range = get_the_category ($ postid); $ Range = $ range [0] - & gt; Cat_name; If ($ range == "pear") {if (comments_open ()) :? & Gt; & Lt; Div class = "comments-link" & gt; & Lt ;? Php comments_popup_link ('& lt; span class = "leave-reply" & gt;' __ ('Leave a reply', '20th'). '& Lt; / span & gt;', __ ('1 answer', 'Twentieth times'), __ ('% answers', 'twentieth')); ? & Gt; & Lt; / Div & gt; & Lt ;! - .comments-link - & gt; & Lt ;? Php endif; // comments_open ()}? & Gt;
and comments.php
in file change:
to
& lt ;? Php $ postid = get_the_ID (); $ Range = get_the_category ($ postid); $ Range = $ range [0] - & gt; Cat_name; If ($ category == "pear") (if (the_comments ()):? & Gt;
and changes:
& lt ;? php endif; // has_comments ()? & Gt; & lt ;? php comment_form ();? & Gt;
to
& lt ;? Php endif; // has_comments ()? & Gt; & lt ;? php comment_form ();}? & Gt;
Only the Pears should display comments in the post in the category.
Comments
Post a Comment