Apr.10

Replacing the wordpress thumbnail (html) display area

WordPress have the add_filter function which can remove or add text to the relevant content area.

We have changed the Title Content and Thumbnail Image by other text or image in my project.

function pkb_my_post_image_html($html, $post_id, $post_image_id ) {

$html = “<a href='”.$pkb_replaced_thumb_href.”‘ target=’_blank’><img src='”.site_url().”/image/myimage.jpg’></a>”;

return $html;
}
add_filter( ‘post_thumbnail_html’, ‘pkb_my_post_image_html’, 10, 3 );

 

There are other filters which we use to our plugin or theme function.

 

Add / Remove Modify Title :

function my_title_replace_filter($title) {

return ‘My added title ::’.$title;

}

add_filter(‘the_title’, ‘my_title_replace_filter’ );

 

Add / Remove Modify Content :

function my_content_replace_filter($content) {

return ‘My added Content::’.$content;

}

add_filter(‘the_content’, ‘my_content_replace_filter’ );

 

add_action( ‘wp_head’, ‘wpcandy_actionhook_example’ );
function wpcandy_actionhook_example () {
echo ‘<meta name=”description” content=”This is the meta description for this page.” />’ ;
} // End wpcandy_actionhook_example()

 

Share this Story:
  • facebook
  • twitter
  • gplus

Leave a comment

Facebook Comment