> For the complete documentation index, see [llms.txt](https://knowledgebase.ajaxsearchpro.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.ajaxsearchpro.com/miscellaneous/post-types/showing-the-post-type-name-in-result-title.md).

# Showing the post type name in result title or content

[What is this, and where do I put this custom code?](/safe-coding-guideline.md)

### Post type name in title

```php
add_filter( 'asp_results', 'asp_show_the_post_type_title', 10, 1 );
function asp_show_the_post_type_title( $results ) {
  foreach ($results as $k=>&$r) {
		if ( isset($r->post_type) ) {
			// Modify the post title
			$post_type_obj = get_post_type_object( $r->post_type );
			$r->title = $post_type_obj->labels->singular_name . ' - ' . $r->title;
		}
  }

  return $results;
}
```

### Post type name in content

```php
add_filter( 'asp_results', 'asp_show_the_post_type_content', 10, 1 );
function asp_show_the_post_type_content( $results ) {
  foreach ($results as $k=>&$r) {
		if ( isset($r->post_type) ) {
			// Modify the post title
			$post_type_obj = get_post_type_object( $r->post_type );
			$r->content = $post_type_obj->labels->singular_name . ' - ' . $r->content;
		}
  }

  return $results;
}
```
