 
			記事のタイトルを入力された内容そのままではなく意図した文章に書き換えたいときは、the_titleにフィルターフックを適用することで実現することができます。
たとえば、本文の頭から20文字取得してタイトルに設定したい場合、以下の記述をfunctions.phpに追加します。
| 1 2 3 4 5 6 | function customTitle($title){ 	global $post; 	$title = mb_substr(strip_tags($post->post_content),0,20) . '...'; 	return $title; } add_filter('the_title','customTitle'); | 
通常のブログやサイトであればタイトルが未入力ということはまず起き得ない状況ですが、WordPRessは本文かタイトルのいずれかが入力されていれば記事として成立するため、Webサービス等でWordPressを使う場合はまれに起きることではないかと思います。
※例えば、私が運営しているWeb制作者の(苦笑)というサービスでは、投稿された記事はすべてタイトルがありません。
ADs
next_post_linkとnext_previous_linkはアーカイブページや個別記事ページなどで前後のページヘのリンクを出力するテンプレートタグです。
このタグを使って前後のページへのリンクを出力している場合、上記のadd_filterを適用させるとなぜかそのページのタイトルになってしまいます。
※$postの内容を利用するような書き換えでない場合はこのような問題は起きません。
get_next_post()とget_previous_post()という関数を利用して前後のページの情報を取得し、その結果と照らしあわせて置換するようにします。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | function customTitle($title){ 	global $post; 	$next_post = get_next_post(); 	$prev_post = get_previous_post(); 	if($post->post_title == $title){ 		$title = $post->jp_title; 	} 	else if($next_post && $next_post->post_title == $title){ 		$title = mb_substr(strip_tags($next_post->post_content),0,20) . '...'; 	} 	else if($prev_post && $prev_post->post_title == $title){ 		$title = mb_substr(strip_tags($prev_post->post_content),0,20) . '...'; 	} 	return $title; } add_filter('the_title','customTitle'); | 
ADs