Viewing 15 replies - 1 through 15 (of 20 total)
  • Hi @ericbullet,

    Actually the event title is a page title if i a not wrong in your case on this page http://spiderhousecafe.com/event/humpday-video-club-presents-die-hard/ it is Humpday Video Club Presents “Die Hard” which is displayed at the top of the page.

    Best Regards,

    Thread Starter ericbullet

    (@ericbullet)

    Of course.

    What i mean is a title in the browser toolbar.

    http://www.w3schools.com/tags/tag_title.asp

    Hi @ericbullet,

    Thank you for your reply.

    Just check header.php file in your theme for the wp_title() function. If it doesn’t exist then add it as specified on the page http://codex.wordpress.org/Function_Reference/wp_title after that customize it using the wp_title filter as described on this page http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title

    For example:
    You can add following code in functions.php file of your theme to display page/post title in browser title bar.

    function custom_wp_title( $title, $sep ) {
    
    	if ( is_feed() )
    		return $title;
    
    	// Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
            else if( is_singular() )
                    $title = "$title $sep". get_the_title();
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 );

    You can also use SEO plugins like following to do this using plugin options instead of custom coding
    http://wordpress.org/plugins/all-in-one-seo-pack/
    http://wordpress.org/plugins/seo-title-tag/ ( Is not tested on WordPress version 3.7 so test it before using it in production site )

    Please advise if you have more questions.

    Cheers.

    Thread Starter ericbullet

    (@ericbullet)

    Hi,

    The titles display fine on all other pages.

    They do not display on pages created by the tribe events calendar.

    thanks.

    Hi @ericbullet,

    In the previous code replace the code
    else if( is_singular() )
    with following code
    else if( is_singular() || is_singular('tribe_events') )

    Kind Regards,

    Hi all!

    @ericbullet does WPMU DEV’s last comment help you? If not, can you confirm if this is only a problem with your particular theme / stack of plugins?

    Thanks!

    Thread Starter ericbullet

    (@ericbullet)

    no.

    function custom_wp_title( $title, $sep ) {
    
    	if ( is_feed() )
    		return $title;
    
    	// Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
            else if( is_singular() )
                    $title = "$title $sep". get_the_title();
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 ); else if( is_singular() || is_singular('tribe_events') )

    Parse error: syntax error, unexpected T_ELSE in /functions.php on line 19

    Hi @ericbullet,

    You have added the provided code in wrong place and not according to what i have told you.

    The correct code is as following.

    function custom_wp_title( $title, $sep ) {
    
    	if ( is_feed() )
    		return $title;
    
    	// Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
            else if( is_singular() || is_singular('tribe_events') )
                    $title = "$title $sep". get_the_title();
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 );

    Regards,

    Thread Starter ericbullet

    (@ericbullet)

    close, now i have site titles twice.
    link

    Hi @ericbullet,

    I have tested the following code on my site and it’s working fine.
    It removes all other existing wp_title filters.

    Just test it using the following code.

    remove_all_filters('wp_title');
    
    function custom_wp_title( $title, $sep ) {
    
    	if ( is_feed() )
    		return $title;
    
    	// Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 );

    Kind Regards,

    Thread Starter ericbullet

    (@ericbullet)

    What is the new code supposed to do?
    It looks like it takes out all titles then adds the site name. Then adds the site description.

    I have ll the titles except for the event titles.

    Hi @ericbullet,

    I have reduced the new code by removing redundant code from it and also removed all existing wp_title hooks.

    After testing a lot i found that some time the post_title doesn’t exist in WP_Post object for tribe_events post type.

    To fix this problem, just add following code in custom_wp_title() function above this // Add the site name. statement.

    if( $title == '' ) {
    	global $post;
    	$post = get_post($post->ID);
    	$title = "$post->post_title $sep ";
    }

    Cheers.

    Thread Starter ericbullet

    (@ericbullet)

    thanks. so do this?

    // Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 );
    if( $title == '' ) {
    	global $post;
    	$post = get_post($post->ID);
    	$title = "$post->post_title $sep ";
    }

    Thread Starter ericbullet

    (@ericbullet)

    actually I mean

    if( $title == '' ) {
    	global $post;
    	$post = get_post($post->ID);
    	$title = "$post->post_title $sep ";
    }
    
    // Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 );

    Thread Starter ericbullet

    (@ericbullet)

    oh i see you mean this:

    <?php
    
    remove_all_filters('wp_title');
    
    function custom_wp_title( $title, $sep ) {
    
    	if ( is_feed() )
    		return $title;
    
    if( $title == '' ) {
    	global $post;
    	$post = get_post($post->ID);
    	$title = "$post->post_title $sep ";
    }
    
    // Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
    
    	return $title;
    }
    add_filter( 'wp_title', 'custom_wp_title', 10, 2 );
    
    ?>

    That works ok. except the titles now show the site name and tagline twice

Viewing 15 replies - 1 through 15 (of 20 total)

The topic ‘Page Titles’ is closed to new replies.