Skip to content

Instantly share code, notes, and snippets.

@Temmyhlee
Forked from About2git/functions.php
Created August 2, 2016 18:44
Show Gist options
  • Save Temmyhlee/c9afb4dba99641f99efaba7fe8a71b86 to your computer and use it in GitHub Desktop.
Save Temmyhlee/c9afb4dba99641f99efaba7fe8a71b86 to your computer and use it in GitHub Desktop.

Revisions

  1. @srikat srikat revised this gist Oct 18, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    * Scope: Posts page and all category archives.
    *
    * @author Sridhar Katakam
    * @link http://sridharkatakam.com/
    * @link http://sridharkatakam.com/display-random-ad-every-second-post-genesis/
    */
    function google_ad() {

  2. @srikat srikat revised this gist Oct 18, 2014. 2 changed files with 6 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    <?php
    //* Do NOT include the opening php tag

    add_action( 'genesis_after_entry', 'google_ad' );
    /**
    * Insert one random ad after every second post.
    3 changes: 3 additions & 0 deletions style.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    .adsense {
    margin-bottom: 60px;
    }
  3. @srikat srikat created this gist Oct 18, 2014.
    26 changes: 26 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    add_action( 'genesis_after_entry', 'google_ad' );
    /**
    * Insert one random ad after every second post.
    *
    * Scope: Posts page and all category archives.
    *
    * @author Sridhar Katakam
    * @link http://sridharkatakam.com/
    */
    function google_ad() {

    if ( ! ( is_home() || is_category() ) ) {
    return;
    }

    if ( ! function_exists( 'dfads' ) ) {
    return;
    }

    global $wp_query;

    if( ($wp_query->current_post % 2) == 1 ) {
    echo dfads( 'groups=50&limit=1&orderby=random&container_class=adsense' );
    }

    }