Public feed #380653

Where to put code?

public text v1 · immutable
Raw Edit
·published 2007-03-04 05:57 UTC
rendered paste body
<?php // loop.php, this file does the heavy lifting
@include(TEMPLATEPATH . '/constants.php');
$the_author = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE ID = '$post->post_author'"); // Author name for author archive pages


if (have_posts()) { // Gets it all going


if (is_single()) { // Single entry ?>
<?php if (function_exists('wp_notable')) wp_notable(); ?>
<?php
$prev_post = '';
$next_post = '';
$prev_post = tarski_get_output("previous_post_link('&laquo; %link');");
$next_post = tarski_get_output("next_post_link('%link &raquo;');");

if($prev_post && $next_post) {
	echo '<p class="articlenav primary-span">' . $prev_post . ' &nbsp;&bull;&nbsp; ' . $next_post . '</p>';
} elseif($prev_post || $next_post) {
	echo '<p class="articlenav primary-span">' . $prev_post . $next_post . '</p>';
} ?>
<div class="primary">
<?php while(have_posts()) { the_post(); ?>
<?php if (function_exists('wp_notable')) wp_notable(); ?>
<?php $trackbackLink = trackback_url(FALSE); ?>
	<div class="entry">
		<div class="meta">
			<h1 class="title"><?php the_title(); ?></h1>
			<p class="metadata"><?php echo tarski_date();
			if(!get_option('tarski_hide_categories')) { _e(' in ', 'tarski'); the_category(', '); }
			if($multipleAuthors) { _e(' by ', 'tarski'); the_author_posts_link(); }
			edit_post_link(__('edit', 'tarski'),' (',')'); ?></p>
		</div>
		<div class="content">
			<?php the_content(); ?>
			<?php if(function_exists(UTW_ShowTagsForCurrentPost)) { // UTW tags
			echo '<p class="tagdata"><strong>'; _e('Tags:', 'tarski'); echo '</strong> '; UTW_ShowTagsForCurrentPost('commalist'); echo '</p>'; } ?>
		</div>
		<?php link_pages_without_spaces();
		echo $postEndInclude; ?>
	</div>
<?php } // End entry loop ?>
</div>



<?php } elseif(is_page()) { // Page (default template) ?>
<div class="primary">
<?php while(have_posts()) { the_post(); ?>
	<div class="entry">
		<div class="meta">
			<h1 class="title"><?php the_title(); ?></h1>
		</div>
		<div class="content">
			<?php the_content(); ?>
		</div>
		<?php link_pages_without_spaces();
		echo $pageEndInclude;
		edit_post_link(__('edit page', 'tarski'), '<p class="metadata">(', ')</p>'); ?>
	</div>
<?php } // End entry loop ?>
</div>



<?php } elseif (is_home() || is_archive() || is_search() || is_tag()) { // Everything else ?>
<div class="primary">
<?php if(is_home()) { // Home page header
// For use when you want something at the top of your home page
} elseif(is_category()) { // Category header ?>
	<div class="archive">
		<div class="meta">
			<h1><?php echo single_cat_title(); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('You are currently browsing the archive for the ', 'tarski'); echo '<strong>'; single_cat_title(); echo '</strong>'; _e(' category.', 'tarski'); ?></p>
		</div>
	</div>
<?php } elseif(is_author()) { // Author header ?>
	<div class="archive">
		<div class="meta">
			<h1 class="title"><?php echo 'Articles by ' . $the_author; ?></h1>
		</div>
		<div class="content">
			<p><?php _e('You are currently browsing ', 'tarski'); echo '<strong>' . $the_author . '</strong>'; _e('&#8217;s articles.', 'tarski'); ?></p>
		</div>
	</div>
<?php } elseif(is_day()) { // Daily archive header ?>
	<div class="archive">
		<div class="meta">
			<h1 class="title"><?php echo tarski_date(); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('You are currently browsing the daily archive for ', 'tarski'); echo '<strong>' . tarski_date() . '</strong>.'; ?></p>
		</div>
	</div>
<?php } elseif(is_month()) { // Monthly archive header ?>
	<div class="archive">
		<div class="meta">
			<h1 class="title"><?php the_time('F Y'); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('You are currently browsing the monthly archive for ', 'tarski'); echo '<strong>'; the_time('F Y'); echo '</strong>.'; ?></p>
		</div>
	</div>
<?php } elseif(is_year()) { // Yearly archive header ?>
	<div class="archive">
		<div class="meta">
			<h1 class="title"><?php the_time('Y'); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('You are currently browsing the yearly archive for ', 'tarski'); echo '<strong>'; the_time('Y'); echo '</strong>.'; ?></p>
		</div>
	</div>
<?php } elseif(is_search()) { // Search results header ?>
	<div class="archive">
		<div class="meta">
			<h1 class="title"><?php _e('Search Results', 'tarski'); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('Your search for ', 'tarski'); echo '<strong>' . $s . '</strong> '; _e('returned the following results.', 'tarski'); ?></p>
		</div>
	</div>
<?php } elseif(function_exists('is_tag')) { if(is_tag()) { // Tag archive header ?>
	<div class="archive">
		<div class="meta">
			<h1 class="title"><?php
			$format = array(
				'pre' => '',
				'single' => '%tagdisplay%',
				'first' => '%tagdisplay%, ',
				'default' => '%tagdisplay%, ',
				'last' => '%tagdisplay%',
				'none' => '',
				'post' => ''
			);
			UTW_ShowCurrentTagSet('tagsetcommalist', $format); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('You are currently browsing articles tagged ', 'tarski'); echo '<strong>'; UTW_ShowCurrentTagSet('tagsetcommalist', $format); echo '</strong>'; _e('.', 'tarski');?></p>
		</div>
	</div>
<?php } } // Closes headers ?>



<?php // General loop including Asides goes here
if(!is_home() && !get_option('tarski_use_pages')) { $posts = query_posts($query_string . '&nopaging=1'); }
while (have_posts()) { the_post(); ?>
<?php if(get_option('tarski_asidescategory') != 0 && in_category(get_option('tarski_asidescategory'))) { // Aside loop ?>
	<div class="aside" id="p-<?php the_ID(); ?>">
		<div class="content"><?php the_content(__('Read the rest of this entry &raquo;', 'tarski')); ?></div>
		<p class="meta"><?php echo tarski_date(); if($multipleAuthors) { _e(' by ', 'tarski'); the_author_posts_link(); } echo ' | '; ?><a href="<?php the_permalink(); ?>"><?php if($post->comment_status == 'open' || $post->comment_count > 0) { comments_number(__('No comments', 'tarski'), __('1 comment', 'tarski'), '%' . __(' comments', 'tarski')); } else { _e('Permalink', 'tarski'); } ?></a><?php edit_post_link(__('edit', 'tarski'), ' (', ')'); ?></p>
	</div>
<?php } else { // Non-Aside loop ?>
	<div class="entry">
		<div class="meta">
			<h2 class="title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to ', 'tarski'); the_title(); ?>"><?php the_title(); ?></a></h2>
			<p class="metadata"><?php echo tarski_date();
			if(!get_option('tarski_hide_categories')) { _e(' in ', 'tarski'); the_category(', '); }
			if($multipleAuthors) { _e(' by ', 'tarski'); the_author_posts_link(); }
			if($post->comment_status == 'open' || $post->comment_count > 0) { echo ' | '; comments_popup_link(__('No comments', 'tarski'), __('1 comment', 'tarski'), '%' . __(' comments', 'tarski'), '', __('Comments closed', 'tarski')); }
			edit_post_link(__('edit', 'tarski'),' (',')'); ?></p>
		</div>
		<div class="content">
			<?php the_content(__('Read the rest of this entry &raquo;', 'tarski')); ?>
		</div>
		<?php link_pages_without_spaces(); ?>
	</div>
<?php } if(is_home() && !$completedBlurb) { $completedBlurb = 1; echo $frontPageInclude; } } // End entry loop ?>
<?php 
// weird code courtesy Kafkaesqui
// http://wordpress.org/support/topic/57912?replies=7#post-312858
// The next two lines break in WP 2.1
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("paged=$paged");
?>
<?php if(is_paged() && get_option('tarski_use_pages')) {
	echo "<p class=\"pagination\">\n";
	if(is_search()) {
		$prev_post = '';
		$next_post = '';
		$prev_post = tarski_get_output("posts_nav_link('','&laquo; Previous results','');");
		$next_post = tarski_get_output("posts_nav_link('','','More results &raquo; ');");
		
		if(strip_tags($prev_post) && strip_tags($next_post)) {
			echo $prev_post . " &sect; " . $next_post;
		} else {
			echo $prev_post . $next_post;
		}
	} else {
		$prev_post = '';
		$next_post = '';
		$prev_post = tarski_get_output("posts_nav_link('','','&laquo; Older entries');");
		$next_post = tarski_get_output("posts_nav_link('','Newer entries &raquo;','');");
		
		if(strip_tags($prev_post) && strip_tags($next_post)) {
			echo $prev_post . " &sect; " . $next_post;
		} else {
			echo $prev_post . $next_post;
		}

	} echo "</p>\n";
} ?>
</div>
<?php } // Closes 'Everything else' section ?>



<?php } // If there are no posts...



elseif (is_search()) { // No results for search ?>
<div class="primary">
	<div class="entry">
		<div class="meta">
			<h1 class="title"><?php _e('No results', 'tarski'); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('Your search for ', 'tarski'); echo '<strong>' . $s . '</strong>'; _e(' returned no results. Try returning to the ', 'tarski'); echo '<a href="' . get_settings('home') . '">'; _e('front page', 'tarski'); echo '</a>'; _e('.', 'tarski'); ?></p>
		</div>
	</div>
</div>



<?php } elseif(function_exists('is_tag')) { if(is_tag()) { // No results for tag ?>
<div class="primary">
	<div class="entry">
		<div class="meta">
			<h1 class="title"><?php
			$format = array(
				'pre' => '',
				'single' => '%tagdisplay%',
				'first' => '%tagdisplay%, ',
				'default' => '%tagdisplay%, ',
				'last' => '%tagdisplay%',
				'none' => '',
				'post' => ''
			);
			UTW_ShowCurrentTagSet('tagsetcommalist', $format); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('There are no articles tagged ', 'tarski'); echo '<strong>'; UTW_ShowCurrentTagSet('tagsetcommalist', $format); echo '</strong>.'; _e('Try returning to the ', 'tarski'); echo '<a href="' . get_settings('home') . '">'; _e('front page', 'tarski'); echo '</a>'; _e('.', 'tarski'); ?></p>
		</div>
	</div>
</div>



<?php } } else { // No dice... ?>
<div class="primary">
	<div class="entry">
		<div class="meta">
			<h1 class="title"><?php _e('Sorry', 'tarski'); ?></h1>
		</div>
		<div class="content">
			<p><?php _e('Looks like there&#8127;s nothing here, sorry. You might want to try the search function. Alternatively, return to the ', 'tarski'); ?><a href="<?php echo get_settings('home'); ?>"><?php _e('front page', 'tarski'); ?></a><?php _e('.', 'tarski'); ?></p>
		</div>
	</div>
</div>



<?php // That's all folks!
} ?>