• Resolved gabu69

    (@gabu69)


    I usually display my top and bottom sidebar ads with hooks in functions.php for example:

    /* Sidebar ad 4th top */
    add_action('genesis_before_sidebar_widget_area', 'sidebartop');
    function sidebartop() {
    	if(  is_singular('post') ){
    ?>
    <div class="sidebarad">
    
    <!-- EMPIEZA ANUNCIO ADSENSE-->
    My ad code
    <!-- TERMINA ANUNCIO ADSENSE -->
    
    </div>
    <?php
    	}
    }

    Is it possible to implement this in ad inserter? If so, how?

    thanks a lot, superb plugin

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Spacetime

    (@spacetime)

    It depends on what are you trying to implement.

    If you would like to have control over the code inserted then do this:

    Replace My ad code with Ad Inserter PHP function (example for code block 1):

    <?php if (function_exists ('adinserter')) echo adinserter (1); ?>

    But it would make sense to replace the whole sidebartop function body with adinserter function:

    /* Sidebar ad 4th top */
    add_action('genesis_before_sidebar_widget_area', 'sidebartop');
    function sidebartop() {
      if (function_exists ('adinserter')) echo adinserter (1); 
    }

    This way you have total control over all the insertion parameters.
    To behave as is_singular('post') simply enable insertion only on posts.

    • This reply was modified 7 years, 9 months ago by Spacetime.
    Thread Starter gabu69

    (@gabu69)

    Yes I mean that code works perfectly in funcitons.php.

    But my question is: Is there any way I can add that code in ad inserter? I noticed its mostly for codes inside the body and theres no option to put custom codes for hooks like this.

    Plugin Author Spacetime

    (@spacetime)

    Not sure if I understand your question.
    User code inserted in code blocks in Ad Inserter is meant to be inserted somewhere.

    Your code needs to be placed and executed in theme or plugin initialization code.

    Thread Starter gabu69

    (@gabu69)

    I mean that is there any way ad inserter will allow placing codes that can inser in hooks, not just in the body of our articles

    Plugin Author Spacetime

    (@spacetime)

    You can not “place code” in hooks.
    Ad Inserter uses standard WP hooks for automatic insertion (to process content).

    But you can also use manual insertion.
    You can use Ad Inserter widgets and place them into any widget position.
    You can also use Ad Inserter shortcodes and place them into all supported places.
    And as you already know you can use PHP function call wherever you like.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using Genesis Hooks inside Ad Inserter?’ is closed to new replies.