• Resolved variaas

    (@variaas)


    Hey guys, I’m returning to the world of wordpress after a long hiatus. I’m learning how themes work and could use a little help.

    For a private post, when the_title() function is called it adds “Private:” to the post’s title. Is there a way to override this?

Viewing 1 replies (of 1 total)
  • Thread Starter variaas

    (@variaas)

    Saw a lot of posts asking the same thing with no reply. I figured it out, so here’s my solution. In my functions.php file for the template I made a small tweak to how the_title function works. Copy and paste the two functions into your functions.php file and replace all instances of the_title() with asv_the_title(). All other functionality of the_title() should still remain the same.

    function asv_the_title($before = '', $after = '', $echo = true) {
    	$title = asv_get_the_title();
    	if ( strlen($title) > 0 ) {
    		$title = apply_filters('the_title', $before . $title . $after, $before, $after);
    		if ( $echo )
    			echo $title;
    		else
    			return $title;
    	}
    }
    
    function asv_get_the_title($id = 0) {
    	$post = &get_post($id);
    
    	$title = $post->post_title;
    
    	return $title;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Prevent the word “Private” in title of private posts’ is closed to new replies.