Support » Plugins and Hacks » Hacks » Modifying custom post type's title

  • Hi,

    I have a problem here, I’m creating a restaurant directory, instead of typing restaurant word in the end of the restaurant’s name for e.g ‘Spice and Hot Restaurant’ in the title field, can we just put Spice and Hot and we coded the restaurant in a function that echoed whenever the title being requested (in header, in post) wherever possible.

    Anybody knew how to do it?

    tq

Viewing 2 replies - 1 through 2 (of 2 total)
  • add_filter( 'the_title', 'tcb_cpt_title_prefix', 10, 2);
    function tcb_cpt_title_prefix( $title, $post_id ){
      if( 'restaurant' == get_post_type($post_id) ) :
        return $title . ' Restaurant';
      endif;
      return $title;
    }

    thanks a lot TCBarrett, it works..

    but there’s only one little problem left, how to print the function into the <title> tag, it doesn’t appeared in it. maybe something to do with wp_title hook?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modifying custom post type's title’ is closed to new replies.