サポート » 使い方全般 » カレンダーに本文を表示させたいです。

  • お世話になります。

    WordPressの機能の一つのカレンダーにて、日にちの部分に投稿した記事の本文を表示させたいのですが、行き詰っています。

    現在の状況は下記の通りです。
    ・当月に3件の記事を投稿(投稿日は1日,22日,30日)
    ・カレンダーを吐き出しているgeneral_template.phpを編集
    ・本文の取得クエリは作成済み
    ・一件目の本文が1日,22日,30日に表示される(ここで詰まってます。)

    ソースコードは以下の通りです。

    //クエリ
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date),post_content
    		FROM $wpdb->posts
    		INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
    		INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    		INNER JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
    		WHERE MONTH(post_date) = '$thismonth'
    		AND YEAR(post_date) = '$thisyear'
    		AND post_type = 'post'
    		AND post_status != 'trash'
    		AND $wpdb->term_taxonomy.taxonomy = 'category'
    		AND $wpdb->terms.slug = 'live'
    		ORDER	BY post_date ASC
    		", ARRAY_N);
    //実際に日にちを吐き出している部分
    for ( $day = 1; $day <= $daysinmonth; ++$day ) {
    		if ( isset($newrow) && $newrow ){
    			if ( $i % 2 == 0){
    					$class_name = "color_2";
    					$i++;
    				}else{
    					$class_name = "color_1";
    					$i++;
    				}
    			$calendar_output .= "\n\t</tr>\n\t<tr class='".$class_name."'>\n\t\t";
    		}
    		$newrow = false;
    
    		if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
    			$calendar_output .= '<td id="today">';
    		else
    			$calendar_output .= '<td>';
    
    		if ( in_array($day, $daywithpost) ) // any posts today?
    				$calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "?cat=5\"><p class='day_number'>$day</p><p class='day_content'>$dayswithposts->post_content</p>";

    何方かご教授宜しくお願い致します。

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック投稿者 haruhisa

    (@haruhisa)

    申し訳ございません。

    開発環境を記載していませんでした。

    WordPress:3.0.4
    ブラウザ:IE8
    PHPバージョン:5.2
    MySQLバージョン:5.0.77
    Webサーバー:Linux CentOS

    宜しくお願い致します。

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「カレンダーに本文を表示させたいです。」には新たに返信することはできません。