• Hey there. I have a page on my website that I don’t want to appear in the main navigation menu at the top of the page. However, my theme doesn’t natively support menus, so I’m looking for alternative means to exclude it. I tried by making it “private.” The only problem with this is that when people navigate to it the title says: “Private: New Car Smell.” I want to remove the “Private” part from it (no pun intended hehe).

    I’m thinking the code I’ll have to edit is in the page.php file, <h2 class="post_page_title"><?php the_title(); ?></h2> and maybe in the functions.php file ` // Query pages.
    $pages = get_pages($r);

    if ( !empty($pages) ) {

    for($i=0;$i<count($pages);$i++)
    {
    $class=”;
    if(is_page($pages[$i]->post_title))
    $class=’ class=”select” ‘;
    $output .='<li>|</li><li><a ‘.$class.’ href=”‘.get_page_link($pages[$i]->ID).'”><span>’.$pages[$i]->post_title.'</span></a></li>’;
    if($limit!=NULL)
    {
    break;
    }
    }`

    But, since I’m not a php programmer (yet) I’m at a loss.

    Here is the website: http://www.stuandthegurus.com/?page_id=126

    Any help would be highly appreciated. Thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • You can add this to your functions.php.

    /**
     *	Remove the word 'protected' or 'private' from post titles with passwords
     */
    function the_title_trim($title) {
    	$title = attribute_escape($title);
    	$findthese = array(
    		'#Protected:#',
    		'#Private:#'
    	);
    	$replacewith = array(
    		'', // What to replace "Protected:" with
    		'' // What to replace "Private:" with
    	);
    	$title = preg_replace($findthese, $replacewith, $title);
    	return $title;
    }
    add_filter('the_title', 'the_title_trim');
    Thread Starter nickandrea19

    (@nickandrea19)

    Well I did that, but instead of displaying the title now it only says “Error 404 – Not Found.”

    Hmm, I have it working on my site. Try commenting out ( add // in front of) the last line.
    //add_filter('the_title', 'the_title_trim');

    Do you still get the same error?

    Thread Starter nickandrea19

    (@nickandrea19)

    Ok actually I got it working now, and didn’t need the ‘//’. I think I actually didn’t put the code in the right place of my functions.php file.

    I had originally put it after this code:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    But this time I put it right before the closing ?>

    Why did it work this time?

    Thread Starter nickandrea19

    (@nickandrea19)

    Hmmm however, now I have another problem, I can’t login to my wordpress control panel. It gives me an error message:

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/99/8109599/html/wp-content/themes/Grunge/functions.php:208) in /home/content/99/8109599/html/wp-login.php on line 353
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/99/8109599/html/wp-content/themes/Grunge/functions.php:208) in /home/content/99/8109599/html/wp-login.php on line 365
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/99/8109599/html/wp-content/themes/Grunge/functions.php:208) in /home/content/99/8109599/html/wp-includes/pluggable.php on line 737
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/99/8109599/html/wp-content/themes/Grunge/functions.php:208) in /home/content/99/8109599/html/wp-includes/pluggable.php on line 738
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/99/8109599/html/wp-content/themes/Grunge/functions.php:208) in /home/content/99/8109599/html/wp-includes/pluggable.php on line 739
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/99/8109599/html/wp-content/themes/Grunge/functions.php:208) in /home/content/99/8109599/html/wp-includes/pluggable.php on line 934

    What is the code at line 208 of your functions.php? This is where the error is coming from.

    You should create a child theme before you start modifying the code. In your case you just need a style sheet and a functions.php file. then you can add support for menus to your functions.php file, and away you go. It’s not very difficult.

    The way you’re doing it is too complicated and you’re messing up your original theme.

    http://codex.wordpress.org/Child_Themes

    I might also suggest that if your theme doesn’t support menus, it might be time to upgrade.

    Thread Starter nickandrea19

    (@nickandrea19)

    @nate – There is no line 208. It doesn’t go that long, at least not in my html editor.

    @billionstrang – So what can I do now that it’s not functioning correctly? I’d prefer not to lose what I’ve made and have to start all over, that would be a real trouble.
    Is there any way to fix my current theme?

    There is some error in your functions.php. It is tough to diagnose without seeing your functions.php.

    Thread Starter nickandrea19

    (@nickandrea19)

    [Code moderated as per the Forum Rules. Please use the pastebin]

    As a rule of thumb, you if have more than ten lines of code please use pastebin to post it. Instructions here.
    http://codex.wordpress.org/Forum_Welcome#Posting_Code

    Second, I don’t see any obvious problems with the code other than it is using two deprecated functions. My best guess is your editor has added extra white space at the end of the file. Take a look at this help document and see if you can’t work through it.

    http://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F

    Thread Starter nickandrea19

    (@nickandrea19)

    Ok thanks, I’ll keep that in mind, thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to change post page title’ is closed to new replies.