How to get the post author data to display it in an html box?

Viewed 196

I'm not very used to working with Wix and I realized that it has a certain limit regarding the Blog layout. I would like to add the author of each post next to the post, but it would be too much work to do post by post.

So I created an HTML box to get the image and name of the author of the post. But I know I'm not doing it right. See:

post

Looking in the documentation the most I found was the function getPost() which returns various information from the post page, but 'author' or 'writer' is not among them.

My question is: is there any way to get the author data to display it in this box? Or, is there a simpler way to get to this desired layout?

Author information doesn't necessarily need to be inside an HTML box, if there's another way to do that, that's fine too!!

1 Answers

As seen on https://www.wix.com/velo/example/custom-post-page

You can get the ID of the post - which you already demonstrated you know how to do via getPost() then use that ID to retrieve the extra post data - which includes the currentPost.author entity that you are looking for. You can also see on the same page how this, and other data from that extra post data, can be brought into the page:

function assignPostDataToUIElements() {
    $w("#authorName").text = `Written by: ${currentPost.author}`
}

User @Arnon De Paula definitely pointed us in the right direction with their link and should receive the bounty if this ends up being the answer you were looking for.

Related