Urgent: Need clarification before purchasing Business Plan

  • Author
    Posts
  • #3399923

    msaap
    Member

    My existing hosting plan is about to expire and I’m planning to purchase Business Plan but before that I need a little clarification. I know we can upload custom themes and plugins if we have business plan but can’t get access to theme editor area as we get in WordPress.org. But I need that to add Adsense code to after certain paragraphs which could be achieved by accessing functions.php file. I think of a solution.
    What if I edit my Genesis Sample Theme’s functions.php file and add my Adsense code and then upload Sample Theme to my WordPress.com account.
    Will this work? Here is the code I am supposed to add:

    //Insert ads after second paragraph of single post content.

    add_filter( ‘the_content’, ‘prefix_insert_post_ads’ );

    function prefix_insert_post_ads( $content ) {

    $ad_code = ‘<div>Ads code goes here</div>’;

    if ( is_single() && ! is_admin() ) {
    return prefix_insert_after_paragraph( $ad_code, 2, $content );
    }

    return $content;
    }

    // Parent Function that makes the magic happen

    function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
    $closing_p = ‘</p>’;
    $paragraphs = explode( $closing_p, $content );
    foreach ($paragraphs as $index => $paragraph) {

    if ( trim( $paragraph ) ) {
    $paragraphs[$index] .= $closing_p;
    }

    if ( $paragraph_id == $index + 1 ) {
    $paragraphs[$index] .= $insertion;
    }
    }

    return implode( ”, $paragraphs );
    }
    Code source: wpbeginner

    The blog I need help with is maapsworld572455605.wordpress.com.

    #3399936

    Hi there!

    To be able to add AdSense to your WordPress.com site, you’ll want to use a plugin like, for example, this one. This way you should not need to edit the php file.

    I hope that helps :)

    Let me know if you have any more questions regarding that.

    #3400474

    msaap
    Member

    Thank you for your reply!
    I just want to will this work or not? Just let me know.
    After editing functions.php file of my Genesis sample theme, can I upload that to my WordPress.com account? Will code be executed at mentioned place or not?
    I know I can use plugins but I don’t want to.

    #3400476

    fstat
    Staff

    Hi there,

    Yes, you can upload your customized theme to your site provided that you’re on the Business plan.

The topic ‘Urgent: Need clarification before purchasing Business Plan’ is closed to new replies.