matthewherbert
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
For this to work, your permalink structure cannot contain post name or ID. For some reason I couldn’t figure out, WP opens the link differently depending on the permalink structure. Here is my site so you can see how I made the adjustment… the calendar always corresponds to the current post:
Open archives-calendar-widget/arw-widget.php to edit. Copy the following code:
/***** MODIFIED BY The Jungle Comic *****/ /* BEGIN MODIFICATION */ // The Query $args2 = array( 'date_query' => array( array( 'year' => $months[$i]->year, 'month' => $months[$i]->month, 'day' => $j ), ), ); $the_query = new WP_Query( $args2 ); // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $postTitle = get_the_title(); $postID = get_the_ID(); } } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata(); $postYear = get_the_date('Y'); $postMonth = get_the_date('n'); $postDay = get_the_date('j'); //Match calendar post dates with the currently displayed post if( $j == $postDay && $months[$i]->year == $postYear && $months[$i]->month == $postMonth ) $spanID = "IsPost"; else $spanID = "NotPost"; /* END MODIFICATION including below---> Added ID="'.$spanID.'" */Paste right after:
if( $j == $todayDay && $months[$i]->year == $todayYear && $months[$i]->month == $todayMonth ) $todayClass = " today"; else $todayClass = "";Immediately below the code you just pasted, add
ID="'.$spanID.'"so that the existing code looks like this:if(in_array ( $j , $dayswithposts ) ) $cal .= '<span ID="'.$spanID.'" class="day'.$last.$todayClass.' has-posts"> <a>year, $months[$i]->month, $j ) .make_arcw_link($post_type, $cats).'> '.$j.'</a></span>'; else $cal .= '<span class="day'.$last.$todayClass.'">'.$j.'</span>';Adjust style using CSS for #IsPost {
Never mind, I figured it out.
Viewing 2 replies - 1 through 2 (of 2 total)