The embed_footer WordPress PHP action is used to print scripts or data before the closing body tag in the embed template.
Usage
add_action('embed_footer', 'your_function_name');
function your_function_name() {
// your custom code here
}
Parameters
- None
More information
See WordPress Developer Resources: embed_footer
Examples
Adding Google Analytics to embed template
This example adds Google Analytics tracking code to the embed template.
add_action('embed_footer', 'add_google_analytics_embed');
function add_google_analytics_embed() {
?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX-Y"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXX-Y');
</script>
<?php
}
Add custom JavaScript to embed template
This example adds custom JavaScript code to the embed template.
add_action('embed_footer', 'add_custom_js_embed');
function add_custom_js_embed() {
?>
<script>
// Your custom JavaScript code here
</script>
<?php
}
Add custom CSS to embed template
This example adds custom CSS code to the embed template.
add_action('embed_footer', 'add_custom_css_embed');
function add_custom_css_embed() {
?>
<style>
/* Your custom CSS code here */
</style>
<?php
}
Add a custom message before the closing body tag
This example adds a custom message just before the closing body tag in the embed template.
add_action('embed_footer', 'add_custom_message_embed');
function add_custom_message_embed() {
echo '<p>Thanks for visiting our site!</p>';
}
Add a custom script for a chat widget
This example adds a custom chat widget script to the embed template.
add_action('embed_footer', 'add_custom_chat_widget_embed');
function add_custom_chat_widget_embed() {
?>
<script>
// Your custom chat widget script here
</script>
<?php
}