Urgent: Need clarification before purchasing Business Plan
-
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: wpbeginnerThe blog I need help with is: (visible only to logged in users)
-
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. -
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.