Re: [解決済み] ベストセラーウィジェットに画像と順位の表示
フォーラム › 使い方全般 › [解決済み] ベストセラーウィジェットに画像と順位の表示 › Re: [解決済み] ベストセラーウィジェットに画像と順位の表示
2011年1月17日 12:59 AM
#61247
参加者
こんにちは。
アドバイスを頂きphpを勉強しながら試行錯誤した結果
add_filter('usces_filter_bestseller', 'my_bestseller_func', 10, 3);
function my_bestseller_func() {
$args = func_get_args();
list($html, $post_id, $index) = $args;
$post = get_post($post_id);
if ( $index == 0 ){
$img = 'http://sample.jp/wordpress/wp-content/themes/welcart_default/images/gold.png';
} elseif ( $index == 1 ){
$img = 'http://sample.jp/wordpress/wp-content/themes/welcart_default/images/silver.png';
} elseif ($index == 2){
$img = 'http://sample.jp/wordpress/wp-content/themes/welcart_default/images/bronze.png';
} else {
}
$list = usces_the_itemImage(0, 40, 40, $post, 'return' ) . '<img src="' . $img . '" />
<li>第' . ($index+1) . '位<a href="' . get_permalink($post_id) . '">' . $post->post_title . '</a></li>
';
return $list;
}
このようにしたら順位、商品画像、アイコン全て表示されるようになりました。
更に質問なのですが、
URLの部分をthemeフォルダまでのパスを取る関数bloginfo('template_directory')
で置き換えようと思ったのですが何度やってもうまく表示されないようです。
ただ単に書き方が間違っているのかもしれませんが、アドバイス頂けないでしょうか?
if ( $index == 0 ){
$img = bloginfo('template_directory') .'images/gold.png';
このように記述していました。