The embed_content WordPress PHP action allows you to insert additional content after the embed excerpt.
Usage
add_action('embed_content', 'your_function_name');
function your_function_name() {
// Your custom code here
}
Parameters
- None
More information
See WordPress Developer Resources: embed_content
Examples
Add a Copyright Notice
Add a copyright notice after the embed excerpt.
add_action('embed_content', 'add_copyright_notice');
function add_copyright_notice() {
echo '<p>© ' . date('Y') . ' Your Site Name. All Rights Reserved.</p>';
}
Add Social Sharing Buttons
Insert social sharing buttons after the embed excerpt.
add_action('embed_content', 'add_social_sharing_buttons');
function add_social_sharing_buttons() {
echo '<div class="social-sharing">';
echo '<a href="https://twitter.com/share?text=' . urlencode(get_the_title()) . '&url=' . urlencode(get_permalink()) . '" target="_blank">Share on Twitter</a>';
echo '<a href="https://www.facebook.com/sharer/sharer.php?u=' . urlencode(get_permalink()) . '" target="_blank">Share on Facebook</a>';
echo '</div>';
}
Add Related Posts
Display related posts after the embed excerpt.
add_action('embed_content', 'add_related_posts');
function add_related_posts() {
$related_posts = new WP_Query(array(
'posts_per_page' => 3,
'post__not_in' => array(get_the_ID()),
'category__in' => wp_get_post_categories(get_the_ID()),
));
if ($related_posts->have_posts()) {
echo '<div class="related-posts">';
echo '<h3>Related Posts</h3>';
echo '<ul>';
while ($related_posts->have_posts()) {
$related_posts->the_post();
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
echo '</ul>';
echo '</div>';
}
wp_reset_postdata();
}
Display Author Information
Show author information after the embed excerpt.
add_action('embed_content', 'display_author_information');
function display_author_information() {
$author_id = get_the_author_meta('ID');
echo '<div class="author-info">';
echo '<h4>About the Author</h4>';
echo '<p>' . get_the_author_meta('description', $author_id) . '</p>';
echo '</div>';
}
Add a Newsletter Signup Form
Insert a newsletter signup form after the embed excerpt.
add_action('embed_content', 'add_newsletter_signup_form');
function add_newsletter_signup_form() {
echo '<div class="newsletter-signup">';
echo '<h3>Subscribe to Our Newsletter</h3>';
echo '<form action="your_form_action_url" method="post">';
echo '<input type="email" name="email" placeholder="Enter your email address">';
echo '<button type="submit">Subscribe</button>';
echo '</form>';
echo '</div>';
}