WordPress.org

Ready to get started?Download WordPress

Forums

How to change post page title (13 posts)

  1. nickandrea19
    Member
    Posted 2 years ago #

    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.

  2. NateJacobs
    Member
    Posted 2 years ago #

    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');
  3. nickandrea19
    Member
    Posted 2 years ago #

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

  4. NateJacobs
    Member
    Posted 2 years ago #

    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?

  5. nickandrea19
    Member
    Posted 2 years ago #

    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?

  6. nickandrea19
    Member
    Posted 2 years ago #

    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
  7. NateJacobs
    Member
    Posted 2 years ago #

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

  8. billionstrang
    Member
    Posted 2 years ago #

    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.

  9. nickandrea19
    Member
    Posted 2 years ago #

    @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?

  10. NateJacobs
    Member
    Posted 2 years ago #

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

  11. nickandrea19
    Member
    Posted 2 years ago #

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

  12. NateJacobs
    Member
    Posted 2 years ago #

    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

  13. nickandrea19
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic