dreamsoftin / flutter_wordpress

Flutter WordPress API
https://pub.dartlang.org/packages/flutter_wordpress
MIT License
198 stars 122 forks source link

How can I fetch post categories and view it #41

Open BinTofajjal opened 4 years ago

BinTofajjal commented 4 years ago
   Text(
          post.categories,
          textAlign: TextAlign.left,
          style: TextStyle(
                   fontSize: 12.0,
                   fontWeight: FontWeight.bold,
                   color: Colors.black,
                   fontFamily: 'TatsamBengaliRndLight',
                 ),
            ),

but it's not working.

Also, can I fetch the author's avatar too? If possible please let me know.

ellie-me commented 4 years ago

You need to filter first your categories before sending that data to the UI because a Category is not a String, it's an object. Here's a snippet that might work for you:

List<String> getCategoryListFriendlyName(List<Category> categories) { final List<String> temp = []; for(Category cat in categories) { temp.add(cat.name); } return temp; }

To get the author Avatar you might need to do another http request to fetch an user, there's a function inside of this library named fetchUser, use that. And inside of the parameters use the author id that is inside of the post.authorID to get the user with the avatar.

aldoyh commented 2 years ago

You can also add "?_embed" at the endpoint to embed more sibling metadata from other tables.