Tuan Anh Hoang-Vu
Tuan Anh Hoang-Vu

Reputation: 1995

How to add a button or box below Post Title?

I'm writing a Wordpress plug-in that will add a button (or any HTML element) below the post title (or above if below is not possible). How can I do that?

Upvotes: 0

Views: 408

Answers (1)

Gavin
Gavin

Reputation: 2567

You want to use the filter responsable for printing titles. I'm not sure exactly which one it is, but here's the function (it's likely single_post_title as demonstrated):

add_filter( 'single_post_title', 'the_post_title', 10, 2 );

function my_more_link( $post_title ) {
    $button_code = "your_button_HTML_here";
    return str_replace( $post_title, $post_title . $button_code );
}

Upvotes: 1

Related Questions