• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Adsense Widget after post titles

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adsense Widget after post titles

This topic is: not resolved
  • This topic has 4 replies, 2 voices, and was last updated 10 years, 5 months ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 29, 2013 at 3:42 am #38373
    Renu Bakshi
    Member

    How to add a custom widget after post titles and place a Adsense widget in that area.

    Pleas give the solution in simple steps wise, as I am new to all this.

    April 29, 2013 at 4:21 am #38377
    Brad Dalton
    Participant

    Link to your site please.


    Tutorials for StudioPress Themes & WooCommerce.

    April 29, 2013 at 4:40 am #38380
    Brad Dalton
    Participant

    Paste this code using a text editor like Notepad++ at the end of your child themes functions.php file:

    Code not displaying? Grab it on Github.


    Tutorials for StudioPress Themes & WooCommerce.

    April 29, 2013 at 6:21 am #38393
    Renu Bakshi
    Member

    My child themes funtions.php file in the wp-content in the cpanel of my service provider (hostgator) has option of using code editor. Can Iuse this code editor instead of using text editor like Notepad++

    I have understood following:

    Step 1: Copy this code from your reply above:

    /** Register new widget & hook widget after title single posts*/
    genesis_register_sidebar( array(
    'id' => 'custom-widget',
    'name' => __( 'Custom Widget', 'genesis' ),
    'description' => __( 'Custom Widget Area', 'childtheme' ),
    ) );
    /**
    * @author Brad Dalton - WP Sites
    *
    * @link http://wpsites.net/
    */
    function custom_widget() {
    	if ( is_single() ) {
    echo '<div id="custom-widget">';
    dynamic_sidebar( 'custom-widget' );
    echo '</div><!-- end #custom-widget -->';
    }
    }
    add_action( 'genesis_after_post_title', 'custom_widget',15 );
    
    Step 2: Go to wp-content in mt c-panel
    
    Step 3: Open functions.php file of my child theme.
    
    Step4: Paste the above copied code at the end of functions.php file
    
    Are the above steps OK.
    
    Another related question: You have told me three options for having ad unit after title of the posts. Which option is better.
    
    Thanks & Regards..........Renu
    April 30, 2013 at 2:55 am #38521
    Brad Dalton
    Participant

    Yes Renu. You can use the built in cPanel editor.

    Which option is best? If you want to use a Adsense plugin then you'll need to add the widget.

    If you want to add the Adsense code directly without using a plugin, then i suggest the custom function which i have already provided in your other thread.

    Using Simple hooks plugin isn't really the best because you might need to add other custom functions to the same hook which will make it messy.

    Using custom functions in your child theme is the best method.

    Suggestion. If you plan on learning about custom coding, please install WordPress locally so you can test the code and the result without having to worry about messing up your live site.

    Use instantwp.com for Windows or MAMP for Mac.


    Tutorials for StudioPress Themes & WooCommerce.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble