Showing posts with label wordpress hooks. Show all posts
Showing posts with label wordpress hooks. Show all posts

Wednesday, September 5, 2012

Modify title tag using wp_title filter

Here is a quick snippet to modify title tag for page, post, category using wp_title hook.

<?php
  add_filter('wp_title', 'modify_title', 20);
  function modify_title($title) {
    return $title . ' foo';
  }
?>

Thursday, August 2, 2012

Contact form 7 custom validation

While building a  wordpress theme for one of my client I came across some validation issues for contact form7 where two data must show logical error when check in date is bigger than the check out date. First, thing came into my mind is to edit the plugin itself, but this is not the proper solution because if client updates the plugin then my codes will broken again.

Another, solution was to use contact form 7's hooks. The filter 'wpcf7_validate_text' provides a way to directly send validation errors when your requirement is not fulfilled.