Title: Can&#8217;t Get Post Data (ID/Custom Fields) with ShortCode inside Query Loop Block
Last modified: January 15, 2023

---

# Can’t Get Post Data (ID/Custom Fields) with ShortCode inside Query Loop Block

 *  [zaidpirwani](https://wordpress.org/support/users/zaidpirwani/)
 * (@zaidpirwani)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/cant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block/)
 * Hello, I have made a shortcode to show POST ID – it works inside a post, but 
   when I use the same shortcode inside a Query Loop Block, I am getting the same
   result on all posts in that query.
 * ![](https://i0.wp.com/i.ibb.co/Pt29vtR/editor-image.jpg?resize=537%2C300&ssl=
   1)
 * ![](https://i0.wp.com/i.ibb.co/L6szKHB/site-image.jpg?ssl=1)
 * **Code for ShortCode**
 *     ```wp-block-code
       function getPostID() {
       	return get_the_ID();
       }
       add_shortcode( 'getPostID', 'getPostID' );
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [zaidpirwani](https://wordpress.org/support/users/zaidpirwani/)
 * (@zaidpirwani)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/cant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block/#post-16374656)
 * Found similar/same issue here, but it seems the person changed the way their 
   site is made – [https://wordpress.org/support/topic/custom-field-via-shortcode-inside-query-loop-block/](https://wordpress.org/support/topic/custom-field-via-shortcode-inside-query-loop-block/)
 * The solutions mentioning global post and other similar methods, I have tried 
   with no change in the outcome.
 *  Thread Starter [zaidpirwani](https://wordpress.org/support/users/zaidpirwani/)
 * (@zaidpirwani)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/cant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block/#post-16374787)
 * Links to Similar Issues and a possible WORKAROUND solution on Github
 * [https://github.com/WordPress/gutenberg/issues/43053](https://github.com/WordPress/gutenberg/issues/43053)
 * [https://github.com/WordPress/gutenberg/issues/35676](https://github.com/WordPress/gutenberg/issues/35676)
 *  [Rahul](https://wordpress.org/support/users/rahulhog/)
 * (@rahulhog)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/cant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block/#post-16525261)
 * [@zaidpirwani](https://wordpress.org/support/users/zaidpirwani/) Did you find
   a solution for this? I have the same problem. Thanks.
 *  Thread Starter [zaidpirwani](https://wordpress.org/support/users/zaidpirwani/)
 * (@zaidpirwani)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/cant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block/#post-16526984)
 * [@rahulhog](https://wordpress.org/support/users/rahulhog/), nah man. I didnt 
   want to do much coding and wanted to see if this would work while using most 
   of gutenberg and blocks… 
   my site still has the issue.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Can’t Get Post Data (ID/Custom Fields) with ShortCode inside Query Loop
Block’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [post meta data](https://wordpress.org/support/topic-tag/post-meta-data/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 7 participants
 * Last reply from: [zaidpirwani](https://wordpress.org/support/users/zaidpirwani/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/cant-get-post-data-id-custom-fields-with-shortcode-inside-query-loop-block/#post-16526984)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
