Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use embed_site_title_html filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
February 25, 2023
5 minutes read

Hey there! So, you’re diving into WordPress hooks, huh? Let’s talk about the embed_site_title_html filter. This hook allows you to filter the site title HTML in the embed footer. It’s super handy when you want to tweak how the site title appears in embeds.

To use the embed_site_title_html filter, you first need to register it using add_filter. You can add this code to the functions.php of your active theme or create a custom WordPress plugin. Personally, I always recommend creating a custom plugin to avoid any issues when you update your theme.

In the examples below, we’ll define a function called weplugins_modify_embed_site_title_html_defaults which takes one parameter. We’ll register it using add_filter. The first parameter is the hook name, the second is the function name, the third is the priority, and the last is the number of arguments (if any) to be passed to the function.

Sometimes, you might need to remove a registered hook. For that, you can use remove_filter to remove the embed_site_title_html filter.

Parameters

Below is the one parameter required to use this hook:

  • $site_title: (string) The site title HTML.

Live Examples

Example 1: Basic Usage of embed_site_title_html Filter

Here’s a simple example to get you started with the embed_site_title_html filter.

    function weplugins_modify_embed_site_title_html_defaults($site_title) {
        // Update the $site_title variable according to your website requirements and return this variable
        return $site_title;
    }
    // Add the filter
    add_filter("embed_site_title_html", "weplugins_modify_embed_site_title_html_defaults", 10, 1);
    

Example 2: Conditional Modification

In this example, we’ll modify the site title based on a condition.

    function weplugins_modify_embed_site_title_html_conditionally($site_title) {
        if (is_home()) {
            $site_title .= ' - Welcome to Our Site!';
        }
        return $site_title;
    }
    // Add the filter with conditional logic
    add_filter("embed_site_title_html", "weplugins_modify_embed_site_title_html_conditionally", 10, 1);
    

Example 3: Removing the Hook

If you need to remove the hook callback, use the example below.

    // Remove the filter
    remove_filter("embed_site_title_html", "weplugins_modify_embed_site_title_html_defaults", 10, 1);
    

Make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.

Access Premium WordPress Plugins

Contact Us

If you’re having any trouble using this hook or need some customization, feel free to contact us. We’re here to help!

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.