Title: Pull shortcode based on current post information
Last modified: December 26, 2018

---

# Pull shortcode based on current post information

 *  [bgbs](https://wordpress.org/support/users/bgbs/)
 * (@bgbs)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/pull-shortcode-based-on-current-post-information/)
 * If I’m viewing a single post and I want to show a custom-shortcode petition button
   related to the current page I’m viewing, how do I tell this custom-shortcode 
   petition button to only show a link that pertains to this post?
 * The shortcode needs to know, that this is the specific page I’m viewing, and 
   this is the specific field button I need to show for this page.
 * `[field petition-button]`
 * If I add
    `<?php the_sub_field( 'petition_button' ); ?>` to the single.php page
   template, then the php script knows to show the petition link based on the page
   I’m viewing. I need the same function, but using custom-shortcode.
 * I hope this makes sense.
    -  This topic was modified 7 years, 5 months ago by [bgbs](https://wordpress.org/support/users/bgbs/).
    -  This topic was modified 7 years, 5 months ago by [bgbs](https://wordpress.org/support/users/bgbs/).
    -  This topic was modified 7 years, 5 months ago by [bgbs](https://wordpress.org/support/users/bgbs/).
    -  This topic was modified 7 years, 5 months ago by [bgbs](https://wordpress.org/support/users/bgbs/).

The topic ‘Pull shortcode based on current post information’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

## Tags

 * [button](https://wordpress.org/support/topic-tag/button/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [single post](https://wordpress.org/support/topic-tag/single-post/)

 * 0 replies
 * 1 participant
 * Last reply from: [bgbs](https://wordpress.org/support/users/bgbs/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/pull-shortcode-based-on-current-post-information/)
 * Status: not resolved