uncatcrea / wp-appkit

WP-AppKit WordPress plugin (create mobile apps connected to WordPress)
http://uncategorized-creations.com/
194 stars 66 forks source link

How to show category title in archive.html #375

Open sheyad opened 5 years ago

sheyad commented 5 years ago

How to show category name in each post on archive.html page?

mleroi commented 5 years ago

Hi @sheyad, this is in fact the exact same process as for displaying category name in post single (single.html) as you asked on our website here.

Once you've added your post's category name to your webservice post data using the _wpak_postdata filter (see examples here), this category name is available both in single.html and archive.html templates (as _post.my_categoryname for example if you named your additionnal post data _my_categoryname in _wpak_postdata filter).

archive.html example:

<% _.each( posts, function( post ){ %>
    ...
    <%= post.my_category_name %>
    ...
<% }); %>

Hope this helps.