Well I have been going over this for some time to get Hybrid to work well with qtranslate, with a lot of help from Justin this is what I came up with. I am sure this will be improved upon….
You need to add this to your functions.php file in your child theme folder
add_filter( 'hybrid_meta_description', 'disable_stuff' );
add_filter( 'hybrid_meta_keywords', 'disable_stuff' );
add_action( 'hybrid_head', 'my_hybrid_meta_description' );
add_action( 'hybrid_head', 'my_hybrid_meta_keywords' );
function disable_stuff( $var ) {
global $post;
return false;
}
function my_hybrid_meta_keywords() {
global $wp_query;
if ( is_home() || is_front_page() ) {
$keywords = __('your keywords with qtranslate quicktags');
}
/* If on a single post, check for custom field key Keywords and taxonomies. */
elseif ( is_singular() && !is_preview() ) {
$keywords = __(get_post_meta( $wp_query->post->ID, 'Keywords', true ));
if ( empty( $keywords ) ) {
$taxonomies = get_object_taxonomies( $wp_query->post->post_type );
if ( is_array( $taxonomies ) ) {
foreach ( $taxonomies as $tax ) {
if ( $terms = get_the_term_list( $wp_query->post->ID, $tax, '', ', ', '' ) )
$keywords[] = $terms;
}
}
if ( !empty( $keywords ) )
$keywords = join( ', ', $keywords );
}
}
/* If we have keywords, join them together into one string and format for output. */
if ( !empty( $keywords ) )
$keywords = '' . "\n";
echo apply_atomic( 'my_hybrid_meta_keywords', $keywords );
}
function my_hybrid_meta_description() {
global $wp_query;
if ( is_home() || is_front_page() ) {
$description = __('your frontpage description with qtranslate quicktags');
}
elseif ( is_singular() ) {
$description = __(get_metadata( 'post', $wp_query->post->ID, 'Description', true ));
if ( empty( $description ) && is_front_page() )
$description = get_bloginfo( 'description' );
elseif ( empty( $description ) )
$description = __(get_post_field( 'post_excerpt', $wp_query->post->ID ));
}
elseif ( is_archive() ) {
if ( is_author() )
$description = get_the_author_meta( 'description', get_query_var( 'author' ) );
elseif ( is_category() || is_tag() || is_tax() )
$description = term_description( '', get_query_var( 'taxonomy' ) );
}
/* Format the meta description. */
if ( !empty( $description ) )
$description = '' . "\n";
echo apply_atomic( 'my_hybrid_meta_description', $description );
}





Recent discussions