Site Index

Since September 27, 2003: <?php get_post_count(); ?> posts, <?php get_comment_count(); ?> comments.

<?php
$posts_per_page = '-1';

$defaultorderby = 'post_date';
$defaultorder = 'DESC';

define('NL', "\n");

function show_year_select() {
global $wpdb, $tableposts, $m;
$m = substr($m,0,4);
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) as year FROM $tableposts ORDER BY year ASC");
$output .= 'All Years'.NL;
foreach ($years as $year) {
$output .= ''.$year.'';
}
$output = ''.NL.$output.''.NL;
echo $output;
}

function show_author_select() {
global $wpdb, $tableusers, $author;
$users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0", ARRAY_A);
$output .= 'All Authors'.NL;
foreach ($users as $user) {
$output .= ''.$user['user_nickname'].''.NL;
}
$output = ''.NL.$output.''.NL;
echo $output;
}

function show_orderby_select() {
global $orderby;
$orderby = explode(' ', $orderby);
$orderby = $orderby[0];
if ($orderby == 'date') {
$output .= 'Date'.NL;
} else {
$output .= 'Date'.NL;
}
if ($orderby == 'title') {
$output .= 'Title'.NL;
} else {
$output .= 'Title'.NL;
}
if ($orderby == 'category') {
$output .= 'Category'.NL;
} else {
$output .= 'Category'.NL;
}
$output = ''.NL.$output.''.NL;
echo $output;
}

function show_order_select() {
global $order;
if ($order == 'ASC') {
$output .= 'Ascending'.NL;
} else {
$output .= 'Ascending'.NL;
}
if ($order == 'DESC') {
$output .= 'Descending'.NL;
} else {
$output .= 'Descending'.NL;
}
$output = ''.NL.$output.''.NL;
echo $output;
}

function archive_header($before='', $after='') {
global $post, $orderby, $month, $previous, $siteurl, $blogfilename, $archiveheadstart, $archiveheadend, $category_name;
$orderby = explode(' ', $orderby);
$orderby = $orderby[0];
if ('date' == $orderby || empty($orderby)) {
$thismonth = mysql2date('m', $post->post_date);
$thisyear = mysql2date('Y', $post->post_date);
$thisdate = $thisyear.$thismonth;
if ($thisdate != $previous) {
$thismonth = mysql2date('m', $post->post_date);
$output .= ' '.$month[$thismonth].' '.$thisyear.'';
}
$previous = $thisdate;
} elseif ('title' == $orderby) {
preg_match('/[a-z0-9]{1}/i', $post->post_title, $match);
$thisletter = ucfirst($match[0]);
if ($thisletter != $previous) {
$output .= "".$thisletter;
}
$previous = $thisletter;
} elseif ('category' == $orderby) {
$thiscategory = $category_name;
if ($thiscategory != $previous) {
$output .= ' '.get_catname($thiscategory).'';
}
$previous = $thiscategory;
}
if (!empty($output)) {
$output = $before.$output.$after.NL;
echo $output;
}
}

function archive_date($format='Y-m-d H:i:s') {
global $post;
echo mysql2date($format, $post->post_date);
}

?>

function Choose(whichSort) {
if (whichSort.selectedIndex == 2) {
document.getElementById('asc_desc').selectedIndex = 1;
} else {
document.getElementById('asc_desc').selectedIndex = 0;
}
}

<?php
//Make sure categories get parsed out, they are deprecated in wp-blog-header.php
if ($HTTP_POST_VARS["orderby"] == 'category') {
if ($HTTP_POST_VARS["order"] == '') $order = "DESC";
$year = '' . intval($HTTP_POST_VARS["m"]);
$author = ''.intval($HTTP_POST_VARS["author"]);
if (empty($author)) {
$whichauthor='';
} else {
$author = ''.urldecode($author).'';
$author = addslashes_gpc($author);
if (stristr($author, '-')) {
$eq = '!=';
$andor = 'AND';
$author = explode('-', $author);
$author = ''.intval($author[1]);
} else {
$eq = '=';
$andor = 'OR';
}
$author_array = explode(' ', $author);
$whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
$whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
}
$whichauthor .= ')';
}

// Author stuff for nice URIs

if ('' != $author_name) {
if (stristr($author_name,'/')) {
$author_name = explode('/',$author_name);
if ($author_name[count($author_name)-1]) {
$author_name = $author_name[count($author_name)-1];#no trailing slash
} else {
$author_name = $author_name[count($author_name)-2];#there was a trailling slash
}
}
$author_name = preg_replace('|[^a-z0-9-]|', '', strtolower($author_name));
$author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'");
$whichauthor .= ' AND (post_author = '.intval($author).')';
}
if (!empty($year)) $where .= ' AND YEAR(post_date)=' . $year;
if (!empty($whichauthor)) $where .= $whichauthor;
?>

Sort By:
" method="post">
<?php show_orderby_select() ?>
<?php show_order_select() ?>
<?php show_year_select() ?>
<?php show_author_select() ?>

<?php
$dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1 ORDER BY cat_name $order");
foreach ($dogs as $catt) {
$categories = $wpdb->get_results("SELECT * FROM $tablepost2cat WHERE category_id = $catt->cat_ID");
if ($categories) {
foreach ($categories as $post2category) {
$posts = $wpdb->get_results("SELECT * FROM $tableposts WHERE $post2category->post_id = ID".$where);
//$category_realname = $wpdb->get_row("SELECT cat_name FROM $tablecategories WHERE cat_ID = $post2category->category_id");
//print_r($category_realname);
global $category_name;
$category_name = $post2category->category_id;
if ($posts) {
foreach ($posts as $post) {
start_wp();
archive_header('', '');
archive_date('m-d-Y h:iA') ?>: ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?>
<?php

}
}
}
}
}
}
else {
require_once ('wp-blog-header.php');
// echo $request;
?>

Sort By:
" method="post">
<?php show_orderby_select() ?>
<?php show_order_select() ?>
<?php show_year_select() ?>
<?php show_author_select() ?>

<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>

<?php //print_r($post); ?>
<?php archive_header('', '

date        
title
author
comments
categories
 

') ?>

<?php archive_date('m-d-Y') ?>
ID) ?>"><?php the_title(); ?>
<?php the_author_posts_link(); ?>
ID) ?>#comments"><?php comments_number('0','1','%') ?>
<?php the_category(', ') ?>

<?php edit_post_link(__('edit'), '', ''); ?>
<?php } }
}?>

 

Community Guidelines

By using this site, you agree to our community guidelines. Inappropriate or disruptive behavior will result in moderation or eviction.

 

Content license

By contributing to OrangePolitics, you agree to license your contributions under a Creative Commons Attribution-NoDerivs 3.0 United States License.

Creative Commons License

 
Zircon - This is a contributing Drupal Theme
Design by WeebPal.