2017-02-10 5 views
1

私はうまくいかないようなことがありました。私はエントリータイトルについて、フロントページに各ポートフォリオ項目の上に(ホバー上に)表示されています。Wordpress:Move entry-title

ここでは、私が何を意味するかを見ることができます。 www.untoldworks.com

私がしようとしているのは、エントリのタイトルをポートフォリオ項目の左側にあるエントリカテゴリ&エントリ日付に沿って表示するように移動することです。

私は、ポートフォリオのページのエントリのメタレイアウトを理解したように、テンプレートtags.php内

function eris_entry_header() { 

if (!is_single() && (!is_search() && ('link' == get_post_format() || 'quote' == get_post_format()))) { 
    return; 
} 

$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; 

if (get_the_time('U') !== get_the_modified_time('U')) { 
    $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; 
} 

$edit_post_link = ''; 

if (is_user_logged_in()) { 
    $edit_post_link = '<a href="' . esc_url(get_edit_post_link()) . '"></a>'; 
} 

$time_string = sprintf($time_string, 
    esc_attr(get_the_date('c')), 
    esc_html(get_the_date()), 
    esc_attr(get_the_modified_date('c')), 
    esc_html(get_the_modified_date()) 
); 

$posted_on = sprintf(
    esc_html_x('%s', 'post date', 'eris'), 
    '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>' 
); 

if ('portfolio' == get_post_type()) { 
    $categories_list = get_the_term_list(get_the_ID(), 'ct_portfolio', '', '&nbsp;', ''); 
} else { 
    $categories_list = get_the_term_list(get_the_ID(), 'category', '', '&nbsp;', ''); 
} 

if (is_single()) { 
    the_title('<h1 class="entry-title">', '</h1>'); 
} else { 
    the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); 
} 

printf('<div class="entry-meta"><span class="category-list">%1$s</span><span class="post-date">%2$s</span><span class="edit-link">%3$s</span></div>', $categories_list, $posted_on, $edit_post_link);} 

を発見されたエントリーのタイトルは、最初の(ポートフォリオ品目のように左下隅)を示しているならばそれは素晴らしいことですその後、エントリカテゴリとその後の日付。

誰かがこれを理解できるといいですか?XD ありがとうございます!

+0

カテゴリと日付でエントリータイトルを表示するだけです。 –

+0

はい、それは計画ですが、どうすればいいのか分かりません。 –

答えて

0

回答/最終更新:あなたが投稿コードから

、最後の行は、関連するものであると思わ:

printf('<div class="entry-meta"><span class="category-list">%1$s</span><span class="post-date">%2$s</span><span class="edit-link">%3$s</span></div>', $categories_list, $posted_on, $edit_post_link);} 

あなたは新しい引数を追加し、引数を使用する必要があります。スワッピング。 これでこの行を交換してみてください:

// use 'get_the_title()' instead of 'the_title()' 
$my_title = get_the_title(); 

// note that I added the "$my_title" to the arguments on the end of the line 
// and also that I added "%4$s" to the printf() function to show our new title 
printf('<div class="entry-meta">%4$s<span class="category-list">%1$s</span><span class="post-date">%2$s</span><span class="edit-link">%3$s</span></div>', $categories_list, $posted_on, $edit_post_link, $my_title);} 

あなたは公式コーデックスページhereprintf()に関するより多くの情報と説明を見つけることができます。

$city = 'New York'; 
$zipcode = '12345'; 

printf('Your city is %1$s, and your zip code is %2$s.', $city, $zipcode); 

になるだろう:より良いこの例では、について説明を見てのために

"あなたの都市は、ニューヨークであり、あなたの郵便番号はです。"


更新:(get_the_titleを使用する前に、())

私は右エントリーメタコンテナの前に、タイトルの新しい要素が間違った場所に追加され、あなたのソースコードで見ることができます。あなたがこれを見たソースコードで

<span class="post-date">Stefan Rustenburg</span> // this is our post-title 
<div class="entry-meta"> 
    <span class="post-date"></span> // this seems to be an empty element ?! 
    <span class="category-list"></span> 
    <span class="post-date"></span> 
    <span class="edit-link"></span> 
</div> 

私はこれまでのコードに変更した場合:

<div class="entry-meta"> 
    <span class="post-date">Stefan Rustenburg</span> // this is our post-title 
    <span class="post-date"></span> // this seems to be an empty element ?! 
    <span class="category-list"></span> 
    <span class="post-date"></span> 
    <span class="edit-link"></span> 
</div> 

タイトルは適切な場所に追加されます。参照してください : post-title on right place

あなたはクラスpost-dateを自分でspan要素を作成しましたか? printf()の機能は現在どのように機能していますか?

P.S. beforeafterなしに変更してみてください。

ではなく、get_the_title()を使用する必要があります。

+0

こんにちはLWS-Moさん、ありがとうございます。私はあなたのコードを実装しました。これは自分自身を試した行に沿ったものです。しかし、奇妙なことは、タイトルはまだポートフォリオ商品の上に印刷されているということです。日付やカテゴリと同じCSSを適用しても。コードの結果を参照してください:[リンク](http://untoldworks.com)私は責任がいくつかのCSSを見ていないのですか? –

+0

デベロッパーツールをウェブサイトで見たことがあります。新しく作成されたタイトル要素が間違った場所に追加されたようです。上記の私の更新答えを見てください。 –

+0

新しいtitle要素がdivの外側に配置されているのは奇妙です。なぜなら、printf()関数を見ると、内部にあるはずですからです。 'printf( '

'、$ categories_list、$ posted_on、$ edit_post_link、$ my_title);また、何もせずにthe_title()を使ってみましたが、表示されません。 –