mnybud Posted February 28, 2011 Share Posted February 28, 2011 First and foremost I am PHP newbie so excuse the dumb question but I have been struggling with this one for hours and can not find the solution. Can someone show me how I would rewite the following wordpress code for meta tags so that it automatically strips out the character ' from the "single" page titles? Example I want this title: "My Cat's Black" to be "My Cats Black" This is the line I am trying to edit..... elseif ( is_single() ) { wp_title(''); print ' | '; bloginfo('name'); } here is the full piece of code... <title><?php if ( is_home() ) { bloginfo('name'); print ' | '; bloginfo('description'); } elseif ( is_search() ) { bloginfo('name'); print ' | '; _e('Search Results', 'woothemes'); } elseif ( is_author() ) { bloginfo('name'); print ' | '; _e('Author Archives', 'woothemes'); } elseif ( is_single() ) { wp_title(''); print ' | '; bloginfo('name'); } elseif ( is_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); } elseif ( is_category() ) { single_cat_title(); print ' | '; bloginfo('name'); } elseif ( is_month() ) { _e('Archive', 'woothemes'); print ' | '; the_time('F'); bloginfo('name'); } elseif (function_exists('is_tag')) { if ( is_tag() ) { bloginfo('name'); print ' | '; _e('Tag Archive', 'woothemes'); print ' | '; single_tag_title("", true); } } ?></title> Any help would be greatly appreciated!! Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/ Share on other sites More sharing options...
mnybud Posted February 28, 2011 Author Share Posted February 28, 2011 anyone? this is making me nuts.... Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1180690 Share on other sites More sharing options...
flolam Posted February 28, 2011 Share Posted February 28, 2011 if you want to strip out only single quote characters you could use str_replace("'", "", "My Cat's Black") Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1180692 Share on other sites More sharing options...
mnybud Posted February 28, 2011 Author Share Posted February 28, 2011 yes I got that but how would I insert it properly in the code above is my problem....can you give a working example with the code above please? Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1180814 Share on other sites More sharing options...
flolam Posted February 28, 2011 Share Posted February 28, 2011 <?php elseif ( is_single() ) { wp_title(''); print ' | '; str_replace("'", "", bloginfo('name')); } ?> Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1180837 Share on other sites More sharing options...
mnybud Posted February 28, 2011 Author Share Posted February 28, 2011 I actually want to replace it in the wp_title portion, how would I modify it to do that since it is using print? <?php elseif ( is_single() ) { wp_title(''); print ' | '; str_replace("'", "", bloginfo('name')); } ?> (thanks a lot for the help) Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1180843 Share on other sites More sharing options...
mnybud Posted February 28, 2011 Author Share Posted February 28, 2011 is it not possible? Everything I try breaks things Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1180905 Share on other sites More sharing options...
flolam Posted March 1, 2011 Share Posted March 1, 2011 so you want to remove the quotes from the return of wp_title? what does this function's definition look like? Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1181348 Share on other sites More sharing options...
samoht Posted March 1, 2011 Share Posted March 1, 2011 I actually want to replace it in the wp_title portion, how would I modify it to do that since it is using print? <?php elseif ( is_single() ) { wp_title(''); print ' | '; str_replace("'", "", bloginfo('name')); } ?> (thanks a lot for the help) the print is merely putting the "|" in the title as a separator I think you want <?php elseif ( is_single() ) { str_replace("'", "", wp_title('')); print ' | '; bloginfo('name'); } ?> Link to comment https://forums.phpfreaks.com/topic/229112-simple-page-title-character-removal-help-needed-please/#findComment-1181357 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.