Core Template Tags
AdSanity ads can be placed programmatically. There are two template tags available for users. One to add a single ad and one to show an ad group. You may want to add these tags to specific templates or template parts to display your advertisements.
To show a single ad: <?php adsanity_show_ad( array( // any valid ad ID will do // (you can get this from the main list of ads) ‘post_id’ => 1, // (one of the following: // alignleft, aligncenter, alignright or alignnone) ‘align’ => false, // this will optionally return the output instead of echoing it ‘return’ => false, )); ?>
To show a group of ads: <?php adsanity_show_ad_group( array( // an array of valid group ids // (you can get these from the main list of ad groups) ‘group_ids’ => array(), // number of ads to show total ‘num_ads’ => 1, // number of ads to show per row ‘num_columns’ => 1, // this will optionally return the output instead of echoing it ‘return’ => false, )); ?>
Add-On Template Tags
To show rotating ads: <?php adsanity_show_rotating_ads( array( // random ads or date-based ordering ‘random’ => true, // any valid group id ‘group_id’ => 0, // (one of the following: alignleft, aligncenter, alignright or alignnone) ‘align’ => false, // how many seconds to show an ad before rotating ‘time’ => 30, // setting a max width can help keep ads responsive, // but also no wider than necessary ‘max_width’ => 0, // this will optionally return the output instead of echoing it ‘return’ => false, )); ?>
To show ordered ads: <?php function adsanity_show_ordered_ads( array( // the number of columns to output ‘num_columns’ => 1, // an array of valid ad ids // (you can get these from the main list of ads) ‘ad_ids’ => array(), // (one of the following: // alignleft, aligncenter, alignright or alignnone) ‘align’ => ‘alignnone’, // this will optionally return the output instead of echoing it ‘return’ => false, ));
Didn’t find what you were looking for?
If you’re a subscriber to AdSanity and don’t find an answer to your specific question please submit a request and our support department will address your issue quickly.