Comment

Properties

PropertyType

ID

int

agent

string

approved

bool

post_ID

int

author

string

author_email

string

author_IP

string

author_url

string

content

string

date

string

date_gmt

string

karma

int

parent

object

post

object

replies

array

user

object

Examples

Handle submission

Handles the submission of a comment, see wp_handle_comment_submission

In an API Controller

$status = Comment::handleSubmission($_POST);

Display comments

{% if post.comment_count %}
<ol class="comment-list">
    {% for comment in post.comments %}
    <li id="comment-{{ comment.ID }}"
        class="comment {{ loop.index is odd ? 'odd thread-odd' : 'even thread-even' }} depth-1 parent">
        <article id="div-comment-{{ comment.ID }}" class="comment-body">
            <footer class="comment-meta">
                <div class="comment-author vcard">
                    <b class="fn">{{ comment.author }}</b>
                </div>
                <div class="comment-metadata">
                    <time datetime="{{ comment.date_gmt }}">{{ comment.date }}</time>
                </div>
            </footer>
            <div class="comment-content">{{ comment.content|raw }}</div>
        </article>

        <div class="comment-reply">
            {% if user %}
            <a rel="nofollow" class="comment-reply-link" href="">
                {{ __( 'Reply to %s' )|format(comment.author) }}
            </a>
            {% else %}
            <a rel="nofollow" class="comment-reply-login" href="{{ login_url(post.link) }}">
                {{ __( 'Log in to Reply' ) }}
            </a>
            {% endif %}
        </div>

        {% if comment.replies|length %}
        <ol class="children">
            {% for reply in comment.replies %}
            <li id="comment-{{ reply.ID }}" class="comment {{ loop.index is odd ? 'odd' : 'even' }} alt depth-{{ depth+1 }}">
                ...
            </li>
            {% endfor %}
        </ol>
        {% endif %}
    </li>
    {% endfor %}
</ol>
{% endif %}

Last updated