Re: 記事ランキングにサムネイル表示
永らくありがとうございました › フォーラム › 使い方全般 › 記事ランキングにサムネイル表示 › Re: 記事ランキングにサムネイル表示
2011 年 1 月 26 日 3:30 PM
#3213
キーマスター
ky982339さん、お久しぶりです。
検証していませんが、
the_qf_get_thumb_one()の仕様によりますと、
the_qf_get_thumb_one($gt_settings = “”, $default_image = “”, $source = Null)
// 記事ソース内の指定された画像を1つ抽出する関数
// $gt_settings
// num=0 : 何番目の画像を取り出すかの指定
// width=0 : 画像の幅指定
// height=0 : 画像の高さ指定
// tag=1 : イメージタグを返すか / 返さないか(返さない場合、画像のURLを返す)
// global=0 : 同一サーバ内のデータに限定するかどうか
// crop_w=0 : クロップ時の横幅
// crop_h=0 : クロップ時の縦幅
// find=string : 検索文字列(全文検索一致データの画像指定)
// $default_image : 画像が無い場合は、ここに指定された値を返す(無ければfalse を返す)
// $source : ソース取得先の指定(無ければ the_content を参照する)
とありますので
先のコードのforeachループ中に、第3引数に$post_data->post_contentを指定した
<code>if(function_exists('the_qf_get_thumb_one')){<br /> echo the_qf_get_thumb_one("num=0&width=60","",$post_data->post_content);<br /> }</code>
を追加して
<code><?php<br /> if (function_exists('counterize_getuniquehitstoday')){<br /> $number = 50;<br /> $wpdb =& $GLOBALS['wpdb'];<br /> $sql = "SELECT p.count as amount, p.url as url, p.url as label, p.postID as post_id , COUNT(m.id) as day_count"<br /> . " FROM " .counterize_logTable(). " m, " . counterize_pageTable(). " p "<br /> . " WHERE m.pageID = p.pageID and p.postID IS NOT NULL and "<br /> . " m.timestamp >= '$onedayago'"<br /> . " GROUP BY p.url "<br /> . " ORDER BY day_count DESC LIMIT $number";<br /> $rows = $wpdb->get_results($sql);<br /> $ranking = 1;<br /> foreach($rows as $row){<br /> $postid = $row->post_id;<br /> $post_data = get_post($postid);<br /> $title = $post_data->post_title;<br /> $ranking_text = $ranking . '位';<br /> $image_url = 'http://example.com/uploads/ranking/ranking_' . $ranking . '.gif';<br /> if (@fclose(@fopen($image_url, "r"))){<br /> echo '<img src="' . $image_url . '" alt="' . $ranking_text . '"/>';<br /> }else{<br /> echo $ranking_text . '' ;<br /> }<br /> <br /> if(function_exists('the_qf_get_thumb_one')){<br /> echo the_qf_get_thumb_one("num=0&width=60","",$post_data->post_content);<br /> }<br /> <br /> echo '<a href="' . $row->url . '">'. $title . '</a><hr style="clear:both;margin-top:3px;">';<br /> $ranking++;<br /> }<br /> }<br /> ?></code>
みたいな感じで取得できるのではなかろうかと思います。