Forums

[resolved] Title PHP Help (Code within TITLE tag) (4 posts)

  1. digitalmikey
    Member
    Posted 11 months ago #

    I'm trying to figure out how to remove a "-" that shows before my bloginfo('name') on the homepage. I am using a static page as the homepage. Basically I want it set up like:

    Main Page (static page):

    bloginfo('name'); echo ' - '; bloginfo('description');

    and all other pages to be like:

    wp_title(''); echo ' - '; bloginfo('name');

    Here is the current code I have:

    <title>
    	<?php
    		$prefix = false;
    
    		 if (function_exists('is_tag') && is_tag()) {
    			single_tag_title('Tag Archive for &quot;'); echo '&quot; - ';
    			$prefix = true;
    		 } elseif (is_archive()) {
    			wp_title(''); echo ' '.__('Archive',EWF_SETUP_THEME_DOMAIN).' - ';
    			$prefix = true;
    		 } elseif (is_search()) {
    			echo __('Search for', EWF_SETUP_THEME_DOMAIN).' &quot;'.wp_specialchars($s).'&quot; - ';
    			$prefix = true;
    		 } elseif (!(is_404()) && (is_single()) || (is_page())) {
    			//if ($prefix == true) {
    				wp_title('');
    				//echo ' - ['.is_bool($prefix).'] ';
    				echo ' - ';
    			//}
    		 } elseif (is_404()) {
    			echo __('Not Found', EWF_SETUP_THEME_DOMAIN).' - ';
    		 }
    
    		 if (is_front_page()) {
    			bloginfo('name'); echo ' - '; bloginfo('description');
    		 } else {
    		  bloginfo('name');
    		 }
    
    		 if ($paged > 1) {
    			echo '  page '. $paged;
    		 }
    
    	?>
    	</title>

    Basically I would like the same structure above just a way to remove the " - " before the bloginfo('name') on the home page.

  2. Digital Raindrops
    Member
    Posted 11 months ago #

    Untested:

    add || is_front_page() use is_singular() to cover posts and pages.

    Change:
    } elseif (!(is_404()) && (is_single()) || (is_page())) {
    To:
    } elseif ( !( is_404() || is_home_page() ) && is_singular() ) {

    HTH

    David

  3. digitalmikey
    Member
    Posted 11 months ago #

    Where am I adding this?

    add || is_front_page() use is_singular() to cover posts and pages.

  4. digitalmikey
    Member
    Posted 11 months ago #

    Nevermind. I got it. Thanks!

Reply

You must log in to post.

About this Topic