WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding Custom fields & Taxonomy Category to Title Tag using All in One SEO Pack (2 posts)

  1. maikunari
    Member
    Posted 2 years ago #

    I am trying to create a custom title tag for a page that is using custom post types.

    What I'd like to have show in the title tag on the single page is:
    <title>Postname | Custom Field:manufacturer | Taxonomy Category Name | Sitename</title>

    I'm using the all in one seo plugin, I'm willing to change to a different plugin (platinum seo, yoast seo, etc) if this format can be created using them.

    Any help or suggestions would be greatly appreciated!

  2. maikunari
    Member
    Posted 2 years ago #

    Here's what I ended up doing:

    <title><?php
    
    if (is_page('inventory')) {
    wp_title( '' );
    
    // inventory page custom title tag
    //$title_tag = get_post_meta($post->ID, 'title', true);
    //	if ($title_tag) { echo $title_tag; }
    
    } 
    
    	global $page, $paged;
    
    if (!is_page('inventory')) {
    	wp_title( '' );
    }
    	// manufacturer custom field
    	$manufacturer = get_post_meta($post->ID, 'manufacturer', true);
    		if ($manufacturer) { echo ' ' . $manufacturer; }
    
    	// category
     	$categories= wp_get_object_terms($post->ID, 'division');
      	echo ' ' . $categories[0]->name;
    
    	// Add the blog name.
    	?> | <?php bloginfo( 'name' );
    
    	// Add the blog description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		echo " | $site_description";
    
    	// Add a page number if necessary:
    	if ( $paged >= 2 || $page >= 2 )
    		echo ' | ' . sprintf( __( 'Page %s', 'ms_base' ), max( $paged, $page ) );
    
    	?></title>

Topic Closed

This topic has been closed to new replies.

About this Topic