• Resolved esearing

    (@esearing)


    I am working on a lawncare services site and I want to edit the widget in sidebar to display monthly archive without a year. The goal is to provide a page with seasonal info regardless of year/day.

    Need to change $is_month so it pulls by month not Month+Year. And need sidebar display to only display month.

    A season (spring, summer, fall, winter) option would be good too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter esearing

    (@esearing)

    I can hard code it using sitename/mm where mm is monthnum 01-12 but that does not quite do it since I may not have posts in March.

    Can anyone point me to the query for the monthly Archive and its output values.I may be able to modify that.

    Thread Starter esearing

    (@esearing)

    I created my own hack to the archives widget in order to get month only without year. You have to modify wp-includes/general-template.php and link-template.php. Here is my hack.

    FIND in wp-includes/general-template.php
    if ( ‘monthly’ == $type ) {

    INSERT ABOVE

    //MONTHONLY CUSTOM TYPE
    $type = 'monthonly';
    if ( 'monthonly' == $type ) {
    		$query = "SELECT MONTH(post_date) AS <code>month</code>, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY MONTH(post_date) ORDER BY MONTH(post_date) $limit ";
    		$key = md5($query);
    		$cache = wp_cache_get( 'wp_get_archives' , 'general');
    		if ( !isset( $cache[ $key ] ) ) {
    			$arcresults = $wpdb->get_results($query);
    			$cache[ $key ] = $arcresults;
    			wp_cache_add( 'wp_get_archives', $cache, 'general' );
    		} else {
    			$arcresults = $cache[ $key ];
    		}
    		if ( $arcresults ) {
    			$afterafter = $after;
    			foreach ( (array) $arcresults as $arcresult ) {
    
                                      /* NOTICE BELOW IS GET_MONTHONLY_LINK FOUND IN link-template.php*/
                                      $url = get_monthonly_link( $arcresult->month);
    
                                    /* translators: 1: month name,*/
    
                                    $text = sprintf(__('%1$s'), $wp_locale->get_month($arcresult->month) );
    				if ( $show_post_count )
    					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
    
                                   $output .= get_archives_link($url, $text, $format, $before, $after);
    			}
    		}
    }
    //END MONTHONLY CUSTOM TYPE

    FIND
    if ( ” == $type )
    $type = ‘monthly’;
    CHANGE TO
    if ( ” == $type )
    $type = ‘monthonly’;

    FIND IN link-template.php
    function get_monthonly_link($year $month) {
    INSERT ABOVE

    //GET_MONTHONLY_LINK
    function get_monthonly_link($month) {
    	global $wp_rewrite;
    	if ( !$month )
    		$month = gmdate('m', time()+(get_option('gmt_offset') * 3600));
    	$monthlink = '';
    	if ( !empty($monthlink) ) {
    		$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
    		return apply_filters('monthonly_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $month);
    	} else {
    		return apply_filters('monthonly_link', trailingslashit(get_option('home')) . zeroise($month, 2), $month);
    	}
    }
    //END GET_MONTHONLY_LINK

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Month without year archive’ is closed to new replies.