Answers.Body: <p>As mentioned in chat.civicrm.org the do_shortcode does work in a single template (single.php for example) but not in a sidebar.   </p>
  
  <p>Two examples to get this going are <a href="https://github.com/aghstrategies/civicontribute-widget" rel="nofollow">https://github.com/aghstrategies/civicontribute-widget</a> and <a href="https://github.com/agh1/civievent-widget" rel="nofollow">https://github.com/agh1/civievent-widget</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-27T06:38:35.683Z
Answers.Text: I have checked this https://github.com/aghstrategies/civicontribute-widget 
  
  this but i can't figure out how can i get petition?
Answers.UserDisplayName: nil108
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-27T11:30:58.617Z
Answers.Text: shortcode is not working in category page and tag page. It's only work in pages and posts. It's means without post id  Shortcode not work.
Answers.UserDisplayName: nil108
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-26T19:31:08.443Z
Answers.LastActivityDate: 2016-08-26T19:31:08.443Z
Answers.UserDisplayName: Kevin Cristiano
Body: <p>I want to show petition in page but using template file. Is it possible?</p>
  
  <p>I have used below shortcode in template file but it not worked.  </p>
  
  <pre><code>&lt;?php echo do_shortcode('[civicrm component="petition" id="1" hijack="0"]');?&gt;
  </code></pre>
  
  <p>Also I want to show another petition in popup but also there shortcode not working</p>
  
  <p>See I want to default petition show in sidebar so i get default petition Id using custom query but i can't get petition with profile form using shortcode. Any other method to get petition using id. See below query for get default petition id.</p>
  
  <pre><code>$petition = civicrm_api3( 'Survey', 'getsingle', array(
              'sequential' =&gt; 1,
              'is_active' =&gt; 1,
              'is_public' =&gt; 1,
              'is_template' =&gt; 0,
              'options' =&gt; array(
                  'limit' =&gt; 1,
                  'sort' =&gt; 'id ASC',
                  'offset' =&gt; CRM_Utils_Array::value( 'offset', $instance, 0 ),
              ),
              'is_default' =&gt; array( '1'),
          ) );
  
  $petition_id= $petition['id']
  </code></pre>
  
  <p>Thanks In advance</p>
  
Tags: <wordpress>
Title: how to "petition" show using do_shortcode in template file in wordpress?
ThreadText: # how to "petition" show using do_shortcode in template file in wordpress?
  
  (Asked by: username_0 on 2016-08-26)
  
  I want to show petition in page but using template file. Is it possible?
  I have used below shortcode in template file but it not worked.  
  
  
  Also I want to show another petition in popup but also there shortcode not working
  See I want to default petition show in sidebar so i get default petition Id using custom query but i can't get petition with profile form using shortcode. Any other method to get petition using id. See below query for get default petition id.
  $petition = civicrm_api3( 'Survey', 'getsingle', array(
              'sequential' => 1,
              'is_active' => 1,
              'is_public' => 1,
              'is_template' => 0,
              'options' => array(
                  'limit' => 1,
                  'sort' => 'id ASC',
                  'offset' => CRM_Utils_Array::value( 'offset', $instance, 0 ),
              ),
              'is_default' => array( '1'),
          ) );
  
  $petition_id= $petition['id']
  
  Thanks In advance
  
  **Tags:** wordpress
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-26. Score: 1
  
  As mentioned in chat.civicrm.org the do\_shortcode does work in a single template (single.php for example) but not in a sidebar.
  
  Two examples to get this going are <https://github.com/aghstrategies/civicontribute-widget> and <https://github.com/agh1/civievent-widget>
  
  > **Comments:**
  > **username_0**: I have checked this https://github.com/aghstrategies/civicontribute-widget   this but i can't figure out how can i get petition?  
  > **username_0**: shortcode is not working in category page and tag page. It's only work in pages and posts. It's means without post id  Shortcode not work.  
  
  ---
  
  