# Random Ads

### Displaying Random Ads&#x20;

#### Display Random Ads using shortcode

* Short code for reference : \[wpadcenter\_random\_ad adgroup\_ids=2 align='center' max\_width='on' max\_width\_value=300 devices=mobile,tablet,desktop]
* Add shortcode as shown in the image below.

![](https://456431625-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhZhxDAXbXHWmZ3dUIK%2F-M_tlw4_GbM5pRc0uG0F%2F-M_tn1Nla8w9C30-ctXC%2Fnew%20random%20shortcode.png?alt=media\&token=cd04b59e-f153-4ff1-9c69-fcf4213321a5)

* Alignment can be "left", "right" and "center".
* Max width can be set to  "on" or "off".
* Max Width Value is the value in pixels.
* To display ads on specific devices, specify the names of devices. If the 'devices' attribute is not provided the ad will be shown on all devices.
* Click on **Publish**/**Update** button to save shortcode.

#### Display Random Ads using Gutenberg Block

{% hint style="danger" %}
Please note that the Gutenberg Block for displaying Random Ad will be deprecated soon. Refer <https://docs.wpeka.com/wp-adcenter/placing-ads/placing-ad-using-consolidated-block-elementor-widget> to replace the Random Ad Gutenberg block with the Consolidated Ad Gutenberg Block.
{% endhint %}

* Select **WPAdCenter Random Ads** block in the editor as shown in the image below.

![](https://456431625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LhZhxDAXbXHWmZ3dUIK-754427264%2Fuploads%2FKaPq3qw6GbPceVquMKtn%2Frandomad2.png?alt=media\&token=9d48e0bc-3bb4-46ed-b4ce-ea91627c76c7)

* Choose ad groups from which random ads will be fetched.
* Set the alignment for the ad.
* To provide maximum width for an ad, enable the **Max Width** option and provide a maximum width value.
* To display ads on specific devices, select the corresponding checkboxes. The changes will take effect on the preview page or live page and not while editing.
* Click on **Publish**/**Update** button.

#### Display Random Ads using Elementor Widget

{% hint style="danger" %}
Please note that the Elementor Widget for displaying Random Ad will be deprecated soon. Refer <https://docs.wpeka.com/wp-adcenter/placing-ads/placing-ad-using-consolidated-block-elementor-widget> to replace the Random Ads Elementor widget with the Consolidated Ad Elementor widget.
{% endhint %}

* Select **WPAdcenter Random Ads** widget in the Elementor, it is present under **General** category.

![](https://456431625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LhZhxDAXbXHWmZ3dUIK-754427264%2Fuploads%2FK4jpgXF3XjiHuf3wLcPv%2Frandomad1.png?alt=media\&token=9d8500ae-e84b-4f6d-a4f7-8245723dc536)

* Select ad groups from which a random ad will be fetched.im
* Specify alignment for the ad.
* To provide maximum width for an ad, enable the **Max Width** option and provide a maximum width value.
* To display ads on specific devices, select the corresponding checkboxes. The changes will take effect on the preview page or live page and not while editing.
* Click on **Publish**/**Update** button.

#### Display Random Ad using widget

* Select **WPAdcenter Random Ad** widget as shown in the image.

![](https://456431625-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhZhxDAXbXHWmZ3dUIK%2F-M_tlw4_GbM5pRc0uG0F%2F-M_tpjAbAYhB1uqx_Tnj%2Fnew%20random%20widget.png?alt=media\&token=6aa7c881-8823-4f30-b0ea-c956a44d36d7)

* Set the title for the widget.
* Select ad groups from which a random ad will be fetched.
* To provide maximum width for an ad, enable the **Max Width** option and provide a maximum width value.
* To display ads on specific devices, select the corresponding checkboxes.
* Click on **Save**.
