Wordpress Bundle
  • What is Wordpress Bundle?
  • Getting started
    • Installation
    • Wordpress
    • Router
    • Cron job
    • Templates
  • Reference
    • Argument resolver
    • Controller
      • AdminAction
      • BlogController
      • FrontAction
      • WordpressAction
    • Entity
      • Block
      • Blog
      • Comment
      • File
      • Image
      • Menu
      • MenuItem
      • Post
      • Term
      • User
    • Repository
      • CommentRepository
      • PostRepository
      • TermRepository
      • UserRepository
    • Service
      • PaginationService
      • BreacrumbService
  • Guides
    • Server requirements
    • Install plugins
    • Use Multisite
    • Gutenberg
    • WP Steroids plugin
      • Image options
      • Maintenance
      • Admin pages removal
      • WYSIWYG Editor
      • Feature Support
      • Multi-site configuration
      • Constants definition
      • ACF configuration
      • Menu
      • Custom Post type
      • Advanced permalink settings
      • Custom Taxonomy
      • Templates
      • Page states
      • External table viewer
      • Roles
      • Optimisations
      • Security
      • Search
    • Twig Cookbook
    • Inject variables in all templates
    • Internationalization
    • Extending Wordpress Bundle
    • Error pages
    • Site health
  • Integrations
    • Advanced Custom Fields
      • Install ACF PRO
  • Extras
    • Migrating from 1.x to 2.0
    • Roadmap
    • Changelog
    • Alternatives
Powered by GitBook
On this page
  • Properties
  • Examples

Was this helpful?

  1. Reference
  2. Entity

Comment

Properties

Property
Type

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

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 %}
PreviousBlogNextFile

Last updated 1 year ago

Was this helpful?

Handles the submission of a comment, see

wp_handle_comment_submission