I would not put that code into the theme. Create a plugin with the following content:
<?php
/* Plugin Name: Millennial Media Ads */
add_action( 'show_ads', 'mma_show_ads' );
function mma_show_ads()
{
# copy your PHP code into this function.
}
In your theme choose the place where you want to show the ads and write:
do_action( 'show_ads' );
That’s all. The benefit is: If the ads don’t work some day, or the ad server was hijacked or whatever, you can just deactivate the plugin and all is fine.
Related Posts:
- Best way to do multiple constructors in PHP
- Using register_activation_hook in classes
- Moving a PHP web-app to WordPress
- How to use multiple query with same meta key
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to create a custom config file and get data using inline JS in a wordpress page
- How to Remove a Filter from the Admin List Table?
- Replacing the NavWalker dropdown element
- Remove commas from WooCommerce checkout addresses fields
- Concatenate site_url and string doesn’t work
- Getting the dropdown menu to redirect to different pages?
- enqueue multiple Google fonts with multiple weights and styles (italic)
- When did wordpress switched requirements to php7?
- 1+1 php counter inside the update_post_meta
- Get taxonomy terms only of the WP_Query current posts
- How to display user nickname (not display name) in PHP template?
- Extract subdomain and relative address from a url
- Custom Template 404 for specific custom post type
- Accessing site’s root from themes folder
- Passing PHP Function Arguments from CLI vs URL
- tracking number field in Woocommerce order [closed]
- Count top level menu items
- Is_template how to add one more template [closed]
- How to complete two other input fields, completed the first
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Remove the first 5 characters of the_title and orderby that
- How to modify URL (add GET values) after front end form submission?
- How to add a do_action on refreshing of WP customizer?
- Replacing mysql_escape_string in a custom plugin when moving to PHP7
- running wp-cron.php using php not wget
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- WordPress displaying content from sub pages
- jQuery code not working when included in functions.php
- Widgets in the loop if active
- Fatal Errors on pluggable.php
- Blob file download problem
- Search form does not work in my website
- Fatal error: Call to undefined function register_new_user()
- Remove the More Link
- stripping tags from excerpt in WordPress is not working
- How to Configure Events List in WordPress to Disappear Event Once Date is Past
- How to display SQL query that ran in WC_Order_Query?
- How to display success message correctly and delete it when the page is refreshed
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- Removing sidebar on category pages
- How to display meta_value array?
- Why my query does not run with prepare
- ‘Bones’ theme: Load stock scripts in footer instead of header?
- Wrap posts p tags in div
- Adding Separator to Breadcrumbs
- Display Custom Field in Sidebar if Value is Present
- Dynamic Menu drops pages?
- Update user repeater meta (ACF) with another user meta field value
- How to set post to draft and not publish if the_content contains certain words?
- Want to unrestrict plugin block
- Search Ajax Call – Use Form Data in Response
- Highlighting Text in Search Results
- Convert a column of a table containing an Array as response in HTML
- is it possible for a URL to filter by tag
- Add Featured Image to Existing Post
- How to get latest post ID in functions.php?
- Billing detail page doesn’t work after I’ve changed the order of the Woocommerce navigation
- Limiting posts based on nested meta_query
- Preserving backslashes in post_content
- How to make a pagination with dropdown selection?
- How can I prevent a shortcode div from extending beyond its boundaries?
- update_post_meta not working, but values are true
- Woocommerce – get daily sales meta
- update_user_meta not working
- Custom woocommerce payment gateway – Form
- wordpress notice
- Change CSS Variable value in Theme Customizer Live Preview
- Importing the style and scripts in the plugin doesn’t work as well as in the theme
- gettint error 400 with AJAX
- Show different number of posts on first Blog listing page
- After using ssl certificate, wordpress doesn’t work
- use with class file into wp_ajax hook
- Trying to add get_the_title hook to this line
- Change username link in admin bar
- Update all posts in custom post types with wp_cron()?
- Child theme not visible in backend
- Custom theme: adding unwanted tags in the content
- how to check if the post id has a new comment?
- How to change this internal image link parameter using PHP?
- php if, else & custom fields – syntax error
- How to create “page” used for generating PDF? [closed]
- How to show all of aspecific post type that has taxonomy and a specific term
- Why isn’t my custom function kicking in from my functions.php file?
- Banner editable from backend
- Shortcoding with Divs
- Adding else if conditional statement to purchased theme
- Reusing the page name class that WordPress adds to body tag
- How to include support for all page types, calendar urls, archive, etc
- archive per year with monthly
- Upgrade wordpress core programmatically with PHP [closed]
- Too many if’s and else if’s ?? – Must be better way [closed]
- How to lock users account until approvation
- WooCommerce: write featured image dimensions to custom fields in product’
- transition_post_status hook, works – but not if the post is new
- How can I change the location where the custom field is displayed in the Quick Edit tab in WordPress