Move question_metas to theme header
Hi all!
I’m trying to blend AnsPress in my new theme as much as possible and in order to do that I’m trying to move the question metas (views, date, category, subscribe button) inside my header. I tried to call the function:
<?php echo ap_question_metas(); ?>
It’s displaying the metas where I want but they have some issues (views and subscribe button counters not reflecting the right amount, no category,…). I have the feeling that I’m calling the function outside of AnsPress “main part” and so it doesn’t relate to anything.
Any idea why and how I can fix this?
Thanks in advance! 😀
Hello Fred,
Its because you are calling it outside the loop. If you want to use it outside loop simply pass question id to ap_question_metas( get_question_id() )
, that’s it.
Cheers.
Hello Fred, will you share your template.
Thank you for your answer Rahul, it does completely make sense… but it’s still not working. Just to be sure: I’m overriding the questions template by creating a “anspress.php” file in my child theme folder. Is that the right way to do it?