SOLVED Accessing current post Id from within custom particle
Posted 8 years 10 months ago
Hello,
I'm building a simple custom particle to display a featured image for the current wordpress post. In order to do that I need to be able to get the current post ID from within the html.twig file. ( i don't want to set the id manually in the particle settings as it will be different for each "single" page )
Re: SOLVED Accessing current post Id from within custom particle
Posted 8 years 10 months ago
Answering my own question: might be useful to others.. My initial post mentioned getting the featured image but the below should get you access to any variable within the returned array..there is an extra step if you want to access the featured image as this only gets you the ID of the thumbnail..
{% set post_id = function('get_the_ID') %}
{% set posts = wordpress.call('Timber::get_posts', post_id) %}
{% if posts is not empty %}
{% for post in posts %}
{{ post.title }}