Sage 9 Structure and Post Meta Logic

Hello,

I was wondering what the best practice is for getting post meta with Sage 9. My previous way was like this - http://pastebin.com/raw/F9xRchz5 - But this seems like it is mixing business logic with the presentation of Sage 9. How do other people handle getting post meta and then just displaying/using that data in partials/views.

Thank you

You can use the sage/template_data filter to pass data to your templates rather than grabbing the data within the template files

Thanks for the response @ben. Is the same possible for post_type Single, Archive and Taxonomy pages or just templates? Can you point me to the file with the filter in so I can read-up on how to implement this? Doing a quick search for template_data isn’t coming up with anything. Cheers

You can use it for anything you’d like. There’s nothing to read at this time as there’s not yet documentation that covers it. Rest assured this will be documented and it’ll also be covered in the book.

You can search the codebase for sage/template_data to see where it’s used, but that doesn’t really matter much.

Cool cheers. Thanks for your time with this and with the project in general :slight_smile:

1 Like