Adsense-Options – possible to use php-code or widget-shortcodes?

  • Hendryk


    Hi there,

    I very much like the theme-option of Graphene to insert ads at the end of posts. On my Website I want to use adsense AND amazon ads. The amazon ads are (in my case) often more content-related.

    Through the Theme-Options I can insert the Adsense-Code, it all works like a charm. Also it is possible (I just tried), to use the amazon-ad codes instead.

    What I now wanted to do is to use a plugin (Datafeedr Random Ads, ) to make this a little bit more random ;-). The result would be that on one page the adsense ads would appear, on the next page the amazon ads.

    Though, I realized this seems not to be possible. The Datafeedr-Plugin offers a PHP-Shortcode to insert the actual ad code chosen randomly.

    Example Code:

    [BBcode]<?php if (function_exists(‘dfrads’)) { echo dfrads(‘3928984’); } ?>[/BBcode]

    If I enter this code in the Adsense-Code area in the theme settings, the code will be truncated. No ads are displayed. I guess that PHP-Code in that field is not allowed?

    I then tried to use a shortcode like

    [do_widget id=text-8″]

    that can display widgets within posts or pages, as I can also just generate a widget with random ads. It turned out that this also does not seem to work – I only get the shortcode I entered, displayed as plain text.

    [strong]Would it be somehow possible to enable PHP-Code for the adsense-settings-field? Or support for shortcodes provided by another plugin?[/strong]


    Syahir Hakim


    Try using the Action Hooks Widget Areas, together with PHP Code Widget.



    Thanks. It took me some time to figure out a solution for this, but it’s okay. I didn’t quite get what I wanted through the hooks, but whatever 😉

    I now use Amazon Ads in the theme-built-in Adsense code field and added a separate widget area through the hook called “graphene_before_bottomsidebar” within “sidebar-footer.php” and applying the custom-css:

    #graphene-dynamic-widget-graphene_before_bottomsidebar {
    background: none repeat scroll 0 0 #E3E3E3;

    In that hook I can just add a widget that suits my needs as stated above. For the built-in ads options, I didn’t find a solution, to replace them with a customizable widget.

Viewing 3 posts - 1 through 3 (of 3 total)

  • You must be logged in to reply to this topic.