1

当社のブログには 3 人の著者がおり、各著者はプロファイル設定で独自のサイト 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/company/http://site.com/author/Admin/.

どうやってやるの?

4

4 に答える 4

6

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/';
    }
    $link を返します。
}
于 2009-05-24T15:14:39.853 に答える
3

胸焼けが最も少ないのはワードプレス>the_author_metaだと思います。

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

これが私たちが20のテーマでそれをした方法です、これは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()
    )
);
}
于 2012-01-02T18:44:32.640 に答える
1

それが .htaccess を使った URL 書き換えで、.htaccess を手で編集することで可能になります。

しかし、 http: //wordpress.org/extend/plugins/redirection/ などのプラグインを使用すると、 必要なことを実行できるように思われる初心者にとっては簡単です。

于 2009-05-20T15:23:33.933 に答える