Native WordPress comments

Roadmap Card

Description

Right now, if people want to show their WP comments they have to fetch the data themselves and build the logic, or use external services like Disqus. We could build a package to do this so users can use WordPress default comment system.

User Stories

As a Frontity user
I want to use the native WordPress comments out of the box
so that I don’t have to rely on a third service or build my own logic

As a WordPress admin
I want to be able to break comments into pages, selecting the number of top level comments
so that I don’t have to load all comments from the beginning

As a WordPress admin
I want to be able to order my comments from older to newer or newer to older
so that I can select depending on each specific case

Possible solution

As @luisherranz suggested, the comments fetch could be handled by wp-source via actions.source.fetch("@comments/1232"), while we could work on a package to expose:

  • Comments : a component that shows both the comments and the form to create a new one.
  • CommentForm a component to create a new comment.
  • actions.comments.create(...) : an action for those themes that want to create the form themselves, but don’t want to implement the logic.

Apart from that, we need to investigate a way to pass down styles to an external component:

This could works, although we aren’t 100% sure:

const commentsStyles = css`
  margin: 0;

  .commentItem {
    color: red;
  }
`;

const Post = ({ ... }) => {
  return (
    <>
      ...
      <Comments className={commentsStyles} />
    </>
  );
}

Btw, we started a Pull Request some time ago and discussed about some aspects there. Let’s continue the conversation here from now.

@luisherranz I like the approach you suggested. I guess both components, the comments and the form, would be minimal and theme developers just have to style them right? Could they even use a processor if they want to modify the logic of the components?

Not really, no, because that’s only for HTML :sweat_smile:

They should be able to subscribe or even overwrite actions.comments.submit if they want.

Hi, have you implemented this package? I tested this method of showing comments but it’s probably only for displaying and no option for posting a new comment. So it’s useless if we can’t add new comments posting method. For this I know we may need to config our WP for accepting post requests too.
I don’t want to use Disqus. So any guide for a noob?

We haven’t implemented this yet. It’s one of our top priorities so I guess we’ll work on it during the coming weeks. Anyway, you may want to take a look at WP REST API Handbook, as you said, you can add new comments using POST - > https://developer.wordpress.org/rest-api/reference/comments/#create-a-comment.

You can also take a look at this guide, the implementation should be pretty similar. Let us know if you finally try it :slightly_smiling_face:

Actually it’s a bit different scenario in my case as I’m using wordpress.com not .org so authentication etc is a bit different. Also I don’t posses any good skills in things like oauth etc. wordpress.com docs are not making sense to me – maybe they’re for experts. However with localhost I used JWT authentication plugin. I test it sort of working but after dumping off I tried with .com and solution not found.

Can you tell me that is frontity has any method of API authorization? Like can I switch frontity to use authenticated API and provide it with username and p/w of admin. I found when we enable a authentication plugin frontity stops grabbing data from public endpoints too