Query Loop Block – Get & display each post id
-
I am using the Query Loop core block to display my latest 3 CPT posts on the homepage, and I would like to retrieve the post id for each post. I want to use a shortcode to display the post id, and I have that shortcode added to the query loop.
but it keeps displaying the homepage post id, instead of each post id.
This is my code:
function dynamic_post_id_shortcode() { //global $post; //$postid= $post->ID; $postid = get_the_ID(); return $postid; } add_shortcode( 'dynamic_post_id', 'dynamic_post_id_shortcode' );
I want to use the shortcode to display it, so what am I doing wrong?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Query Loop Block – Get & display each post id’ is closed to new replies.