• Patch for enabling per-category random posts:

    --- sideblog.php.orig	2009-01-06 15:57:01.000000000 -0600
    +++ sideblog.php	2009-01-06 15:57:11.000000000 -0600
    @@ -139,6 +139,12 @@
     	$wp_query->set('category__in', array($asideid));
     	$wp_query->set('posts_per_page', $limit);
     	$wp_query->set('category__not_in',array());
    +
    +	// Set random option if set for the category
    +	if($sideblog_options['random'][$asideid]) {
    +		$wp_query->set('orderby', 'rand');
    +	}
    +
     	$sideblog_contents = $wp_query->get_posts();
     	$patterns[] = "%title%";
     	$patterns[] = "%content%";
    @@ -258,6 +264,11 @@
     				$excludefromfeeds = "checked='checked'";
     			}
    
    +			$random = "";
    +			if(isset($sideblog_options['random'][$row->id])){
    +				$random = "checked='checked'";
    +			}
    +
     			$setaside = "";
     			if(isset($sideblog_options['setaside'][$row->id])){
     				$setaside = "checked='checked'";
    @@ -305,7 +316,8 @@
     			$catlist .= "<td align='center'><input type=\"text\" name=\"sideblog_options[displayformat][" . $row->id . "]\" value=\"" . $displayformat . "\" style=\"width:90%;\"/></td>\n";
     			$catlist .= "<td align='center'><select name=\"sideblog_options[numentries][" . $row->id . "]\">" . $numentries . "</select></td>";
     			$catlist .= "<td align='center'><select name='sideblog_options[order][" . $row->id . "]'>" . $order_options . "</select></td>";
    -			$catlist .= "<td align='center'><input type=\"checkbox\" name=\"sideblog_options[excludefromfeeds][" . $row->id . "]\" value=\"" . $row->id . "\" " . $excludefromfeeds . "/></td>\n</tr>\n";
    +			$catlist .= "<td align='center'><input type=\"checkbox\" name=\"sideblog_options[excludefromfeeds][" . $row->id . "]\" value=\"" . $row->id . "\" " . $excludefromfeeds . "/></td>\n";
    +			$catlist .= "<td align='center'><input type=\"checkbox\" name=\"sideblog_options[random][" . $row->id . "]\" value=\"" . $row->id . "\" " . $random . "/></td>\n</tr>\n";
     		}
     	}
    
    @@ -331,6 +343,8 @@
     							</th>
     							<th width="8%">Exclude from Feeds
     							</th>
    +							<th>Random
    +							</th>
     						</tr>
     						' . $catlist . '
     					</table>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Sideblog WordPress Plugin] Sideblog random posts per category’ is closed to new replies.