2009-05-15 7 views
0

当社のブログで3人の作家、は各著者がプロファイル設定で自分のサイトのURLを持っているがあります。異なる1(ワードプレス)で、著者のURLを交換し

Mike - http://mike.com 
Gelens - http://gelens.com 
Admin - http://site.com/company/ 

プロフィールへのリンクは次のとおりです。

http://site.com/author/Mike/ 
http://site.com/author/Gelens/ 
http://site.com/author/Admin/ 

一部のページに<?php the_author_posts_link(); ?>タグがあり、作成者が管理者の場合、リンクはhttp://site.com/author/Admin/ではなくhttp://site.com/company/である必要があります。

どうすればいいですか?

答えて

3

the_author_posts_link関数はget_author_posts_urlを呼び出すだけでリンクを取得し、返す前にauthor_linkフィルタを通過するように見えます。あなたのテーマのfunctions.phpでは、あなたが(未テスト)このような何かを追加することができます。

add_filter('author_link', 'admin_author_link', 10, 3); 
function admin_author_link($link, $author_id, $author_nicename) { 
    if($author_id==1) { 
     $link = 'http://site.com/company/'; 
    } 
    return $link; 
}
0

httpリライトを使用してこれを行うことができます。

1

これは、.htaccessを手で編集することで可能な、.htaccessによるURL書き換えです。

しかし、それはあなたが必要なものを行うように思われるhttp://wordpress.org/extend/plugins/redirection/のようなプラグインで初心者の方が簡単です。

3

私は少なくとも胸焼けがwordpress > the_author_metaになると思います。

あなたが行ったように、各ユーザーが自分のURLをワードプレスのユーザープロフィールに追加させます。あなたのテーマのfunctions.phpthe_author_meta('user_url')を使用してください。 URLをエコーし​​ます。変数として使用するにはget_the_author_meta('user_url')を使用します。ここで

が、これは何を変更するのfunctions.phpのライン568の周りにあるfunctions.php

function twentyten_posted_on() { 
printf(__('<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten'), 
    'meta-prep meta-prep-author', 
    sprintf('<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>', 
     get_permalink(), 
     esc_attr(get_the_time()), 
     get_the_date() 
    ), 
    sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', 
     get_the_author_meta('user_url'), //changed from get_author_posts_url(get_the_author_meta('ID')), 
     sprintf(esc_attr__('About %s', 'twentyten'), get_the_author()), 
     get_the_author() 
    ) 
); 
} 
+1

であり、我々は20 10のテーマでそれをやった方法です。 'esc_url(get_the_author_meta( 'URL')get_the_author_meta( 'URL')::?get_author_posts_url(get_the_author_meta( 'ID')))があり、' ここでは何のウェブサイトが指定されていない場合は、著者の記事にフォールバックの代替でありますまた、49行目と63行目のcontent-single.phpにあるスポットです – groovenectar

関連する問題