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.

<?php echo do_shortcode('[civicrm component="petition" id="1" hijack="0"]');?>

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


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

  • I have checked this github.com/aghstrategies/civicontribute-widget this but i can't figure out how can i get petition? – nil108 Aug 27 '16 at 6:38
  • 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. – nil108 Aug 27 '16 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.