• Anna
    May 6, 2015 at 8:58 am #107929

    This is from the client who tried this – but I cannot confirm if it works on not. Please do backups if you are not sure

    --start copy
    
    done with the plugin "Custom Post Type Permalinks" and a small function in our child template to rewrite the <title>:
    
    // ***************************************************************************************************************
    // better property listing-<title> for WPRESIDENCE
    // ***************************************************************************************************************
    add_filter('wp_title', 'filter_pagetitle');
    function filter_pagetitle($title) {
    //check if its a blog post
    if (!is_single())
    return $title;
    
    global $wp_query;
    if (isset($wp_query->post->post_title)){
    
    $title = $wp_query->post->post_title." | ";
    if(get_post_meta(get_the_ID(), 'property_city', true)!=='')
    $title .= get_post_meta(get_the_ID(), 'property_city', true)." | ";
    $taxonomy = get_the_terms( $post->ID, 'property_category' );
    foreach ( $taxonomy as $term ) 
    {
    $title .= $term->name." | ";
    }
    $taxonomy = get_the_terms( $post->ID, 'property_action_category' );
    foreach ( $taxonomy as $term ) 
    {
    $title .= $term->name." | ";
    }
    
    return $title;
    }
    
    //if wordpress can't find the title return the default
    return $title;
    }
    
    generates a perfect SEO title like <post-title> | <city> | <category> | <action> | <domain>
    
    Please feel free to use that solution for other clients.
    
    --end copy--
    • This topic was modified 2 years ago by  Anna.
    • This topic was modified 2 years ago by  Anna.
    • This topic was modified 2 years ago by  Anna.

The forum ‘Custom Work’ is closed to new topics and replies.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.