Custom Filter in WordPress to modify footer information via plugin?

Most of the footer is straight-up PHP/HTML markup. You apply filters to dynamic content, which is why there isn’t a typical footer “filter.” That said, it’s relatively easy to add your own filters to WordPress.

Let’s say your footer.php consists of the following:

</div>    <!-- close main content div>
<div id="footer">
    <p class="copyright">Copyright 2011 By Me</p>
</div>
</body>
</html>

And lets say you want to dynamically replace the word “copyright” with the standard C image using your filter. You’d replace this with:

</div>    <!-- close main content div>
<div id="footer">
    <p class="copyright">
    <?php
    echo apply_filters( 'my_footer_filter', 'Copyright 2011 By Me' );
    ?>
    </p>
</div>
</body>
</html>

This creates a custom filter called “my_footer_filter” and applies it to the text “Copyright 2011 By Me.” In your functions.php file, you can use this filter just like you would any other:

function replace_copyright( $copyright ) {
    // do something to $copyright
    return $copyright;
}
add_filter( 'my_footer_filter', 'replace_copyright' );

Leave a Comment

error code: 523