How to Create WordPress plugin


plugins literally ‘plug in’ to WordPress core. This is done using ‘hooks,’ which enable one piece of code to interact with another. As such, hooks determine when and where on your site a plugin is actually used.

add_action( 'the_content', 'my_thank_you_text' );

function my_thank_you_text ( $content ) {
    return $content .= '<p>Thank you for reading!</p>';

add_action is ADDing the new function to the another one.

Creating A WordPress Plugin Is Easier Than You Think

function dh_modify_read_more_link() {
return '<a class="more-link" href="' . get_permalink() . '">Click to Read!</a>';
add_filter( 'the_content_more_link', 'dh_modify_read_more_link' );

==> add_filter is telling WP to replace the old core function "the_content_more_link" by this new one "db_modify_read_more_link".


The final line in this code uses a filter to hook into a function called the_content_more_link, which represents the Read More link. The filter instructs WordPress to call our new function instead, so the standard link will be replaced with our new version.

Leave a Reply

Please Login to comment
5 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
HanTang Recent comment authors
Notify of