• Is there any way to stop a page title from having the pre-fix “Private:” when making a page private? I’d like to make some pages private because they don’t need to be part of the menu or clutter up the blog. It’s great I can link to them. I thought to hardcode the side-menu but is that the only solution?

Viewing 15 replies - 1 through 15 (of 19 total)
  • 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;
    }

    A question of clarification –

    do we replace the_title() throughout the site or just on the functions.php page?

    Even if the entire site – should be simple find&replace command, or are there any places where we shouldn’t be replacing it?

    I went with my assumptions above. I saved all the file in advance, which was good, as what I did didn’t work. Not sure why… and unmade the edits before I forgot what all I was doing.

    Maybe I didn’t do it right…

    What if the theme does not have a functions.php page at all?

    Jsut create an empty plain (text) file and save it as functions.php. Copy the code into it. Upload.

    moshu, that did not work for me, for some reason. I don’t know why.

    However, I achieved the same effect by modifying a function in wp-includes/post.php as follows:

    function get_the_title($id = 0) {
    	$post = &get_post($id);
    
    	$title = $post->post_title;
    	if ( !empty($post->post_password) )
    		$title = sprintf(__('Protected: %s'), $title);
    	//else if ( 'private' == $post->post_status )
    		//$title = sprintf(__('Private: %s'), $title);
    
    	return $title;
    }

    The only thing I changed was adding comment slashes to the “else if” lines. However this affects private posts as well as private pages, and would have to be repeated upon upgrading, so it’s not a very good solution.

    Well, the method above has 2 [two] steps:
    a. create the functions.php file
    b. replace ALL the instances of the_title with whatever is given above in the post

    Ok, just applied variaas’s code to my functions.php. In my case the only the_title I changed was the one in Page Template file. Works a treat. Thanks variaas.

    I used drchrisheard’s solution, which worked better for me.

    Another option – which does not require any coding – is to set up a private main page and then set up non-private sub pages. The links you include are to these sub pages and they do not get displayed with the PRIVATE: heading.

    Glad that worked for your blacloch.

    @tfleming and drchrisheard – if at all possible, I avoid editing core files. In the case of upgrading, you’ll have to reapply the fix to the post.php file.

    I tried both and it didn’t work for me.

    Does someone have a simple way to remove

    *private* from private posts.

    any help would be appreciated

    found this elsewhere:

    To get rid of the “Private: ” you can change the WordPress files yourself. I think I tried this once on an experimental blog that I have since binned.

    I think the only file to change is in wp-includes and is post-template.php

    “Private: ” (and a parallel for Protected posts) is part of the get_the_title function. It’s just some printed out text (sprintf). Change it to whatever you want, including nothing (as a string).

    Yessssss, leo6663, that helped me perfectly.

    Thanks for everybodys input.

    Ciao.

    The weird part is, I inputted the code from above into my functions.php file and in development it worked great. Once I moved to production the “Private” still appeared. Any ideas why that would happen. Same files, same version of wordpress. Different database.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Remove the word *Private* on Private Pages’ is closed to new replies.