Title: Post without title insert permalink
Last modified: August 21, 2016

---

# Post without title insert permalink

 *  [tasver85](https://wordpress.org/support/users/tasver85/)
 * (@tasver85)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/post-without-title-insert-permalink/)
 * Hi, i’m trying to pass the [“Theme unit test”](http://codex.wordpress.org/Theme_Unit_Test)
   on a development alpha site.
    This is my first experience in html, css, php and
   wordpress, i’m a noob.
 * I would like to insert a title like “No title” into the post without the title
   and without the permalink.
 * This post is in the “Theme unit test” but i can’t find the way to insert the 
   permalink on the date as the post suggest.
 * The post in the website is the fourth on page 4 [http://filmandnovel.altervista.org/blog/page/4/](http://filmandnovel.altervista.org/blog/page/4/)
 * This is what the post says.
 * > This post has no title, but it still must link to the single post view somehow.
   > This is typically done by placing the permalink on the post date.
 * And this is my code for getting the title and permalink,
 *     ```
       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       		<h2><a href="<?php the_permalink(); ?>" title="<?php the_title();?>">
       		<?php the_title(); ?>
       		</a></h2>
       ```
   
 *  i tried many solution with if and else but nothing worked and still no title
   appear.
 * Thanks for your attention

Viewing 1 replies (of 1 total)

 *  [bu130932](https://wordpress.org/support/users/stham/)
 * (@stham)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/post-without-title-insert-permalink/#post-4673805)
 * I’m not sure if there are other ways to do it, but I usually use the ‘the_title’
   filter hook.
    Try something like this:
 *     ```
       function stham_the_title ( $title ) {
   
       	if ( in_the_loop() && ! is_page() ) {
       		if ( ! $title )
       			$title = __( 'No title', 'stham' );
       	}
       	return $title;
   
       }
       add_filter( 'the_title', 'stham_the_title' );
       ```
   
 * However, the above only changes the title in the blog listing page (if I remember
   correctly). The title could still be blank in other spots, e.g. between your 
   <title> tags (you can use the ‘wp_title’ filter hook for that). I can’t quite
   remember now what other spots might still be sporting a blank post title. Just
   check carefully when you’re doing your testing.
 * For more info:
    [Hooks](http://codex.wordpress.org/Plugin_API/Hooks) [the_title](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title)
   [wp_title](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title)
 * I may be wrong here but I believe all posts will have permalinks. WordPress will
   auto-generate the permalink based on your post’s title. If there’s no title, 
   I believe it uses the post’s ID.
 * Also, [the_title()](http://codex.wordpress.org/Function_Reference/the_title) 
   is not suitable to be used as part of the title attribute in a link. Use [the_title_attribute()](http://codex.wordpress.org/Function_Reference/the_title_attribute)
   instead.
 * Hope that helps.

Viewing 1 replies (of 1 total)

The topic ‘Post without title insert permalink’ is closed to new replies.

## Tags

 * [theme unit test](https://wordpress.org/support/topic-tag/theme-unit-test/)

 * 1 reply
 * 2 participants
 * Last reply from: [bu130932](https://wordpress.org/support/users/stham/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/post-without-title-insert-permalink/#post-4673805)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
