All pastes #1674073 Raw Edit

The sticky posts to integrate wi

public text v1 · immutable
#1674073 ·published 2009-11-16 22:12 UTC
rendered paste body
<?php
require_once dirname( __FILE__ ) . '/form_process.php';
get_header( ); 
include_classified_form( );
?>
<link href="styles/blue.css" rel="stylesheet" type="text/css" />


	<div class="content">
	

	
		<ul id="catnav">
            <li<?php if ( is_home() ) { echo " class=\"current-cat\""; } ?>><a href="<?php bloginfo('url'); ?>" ><?php _e('Latest Listings','cp'); ?></a></li>
			<?php wp_list_categories('show_count=0&hide_empty=true&orderby=name&order=asc&title_li='); ?>
			<li><div class="clear"></div></li>
        </ul>
		
		<?php if ( is_category() && function_exists('bcn_display')) { ?>	
			<div class="subnav">
				<small><?php if(function_exists('bcn_display')) { bcn_display(); } ?></small>
			</div>
		<?php } ?>
		
		<div class="main">
		
			<div class="listing">
				<div class="head">
				
									<span class="location">
					<?php _e('Location','cp'); ?>
					<a href="?sort=meta_value&key=location&order=asc"><img src="<?php bloginfo('template_url'); ?>/images/sortup.png" border="0" /></a><a href="?sort=meta_value&key=location&order=desc"><img src="<?php bloginfo('template_url'); ?>/images/sortdown.png" border="0" /></a>
					</span>
				

				<?php echo 'Actualmente hay ' . $numposts . ' anuncios' . ' ,distribuidos en ' . $numcats . ' categorias.';?>
				<div class="clear"></div>  
			  </div>
			  
				<div class="list">
					<?php 
					$i = 1; 
					
					if(!empty($_GET['sort']))
					{
					$orderby=trim($_GET['sort']);
					$order=trim($_GET['order']);
					$key=trim($_GET['key']);
					
					
					// create the sort by injection
					$posts = query_posts($query_string . '&orderby='.$orderby.'&meta_key='.$key.'&order='.$order.'');
					}
					
					if (have_posts()) : ?>
					
					<?php while (have_posts()) : the_post(); ?>
					
					<?php if ($i % 2 == 0) { $alt = " class=\"alt\""; } else { $alt = " class=\"no\""; } echo "<div" . $alt;
					if (is_sticky()) { echo " id='sticky' "; } echo ">"; 
					?>				
						
				  <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
									
					<?php if ( get_option('main_page_img') != "no" ) { ?>
					
                  <span class="date"><div><?php the_time(get_option('date_format')) ?></div>
				  <?php the_time(get_option('time_format')) ?></span>	
			

						<span class="image">	
							<?php $images = get_post_meta($post->ID, "images", true);
								if (empty($images)) {?>
								    <div class="main_page_no_img"><img src="<?php bloginfo('template_url'); ?>/images/no-pic.png" alt="Sin Foto" border="0" /></div></span>
								<?php } else { ?>
								<div class="main_page_img" style="background: transparent url(<?php echo get_bloginfo('template_url')."/includes/img_resize.php?width=90&height=70&url=";?><?php
										  if ( strstr($images, ',')) {  
											$matches = explode(",", $images);
											$img_single = $matches[0];
											$img_single = explode(trailingslashit(get_option('siteurl')) . "wp-content/uploads/classipress/", $img_single);
											echo $img_single[1];
										  } else {
											$img_single2 = $images;
											echo $img_single2;
												}?>) no-repeat"></div></span>
								<?php 
								} 
									} else {
										$ii = 1;
										echo "<span class='cat_image'>";
										foreach((get_the_category()) as $category) {
											if ($ii == "1") {
												$cat_image = get_bloginfo('template_url')."/images/category-icons/".get_option("cat$category->cat_ID").".png";
												echo "<img src=" . $cat_image . ">";
												$ii++;
											}
										}
										echo "</span>";
									} ?>
								
				  <span class="item">
				  <div class="titulo"><?php if ( strlen(get_the_title()) > 65 ) { echo substr(get_the_title(), 0, 65)."..."; } else { the_title(); } ?>
				 
				  </div>
				  <div class="contenido"><?php echo substr(strip_tags($post->post_content), 0, 150)."...";?></div>
				   
                  <div class="precio"><?php echo get_post_meta($post->ID, "price", true); ?> <?php echo get_option('currency'); ?></div></span></a>
				  <span class="location"><?php echo get_post_meta($post->ID, "location", true); ?></span>
				 <div class="clear"></div>
			  </div>
						
					<?php $i++; unset($alt); ?>
					
					<?php endwhile; ?>
					

						<div class="navigation1">
						<div class="navigation2">
						
						<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else {  ?>
						
							<div class="alignleft">
								<?php next_posts_link('<div class="next_post_link"></div>') ?>
							</div>
							<div class="alignright">
								<?php previous_posts_link('<div class="previous_post_link"></div>') ?>
							</div>
							
						<?php  } ?>
						
						</div>
						<div style="clear:both;"></div>
						</div>
					<div style="clear:both;"></div>
					
					<?php endif; ?>
					
		  </div>
			</div>
		</div>
	</div>
	
<?php
//code to prune posts.
if (get_option("post_prun") == "yes" && get_option("prun_period") != "" && get_option("post_prun") != "") {
	$prun_period = get_option("prun_period");
	$sql = "SELECT `ID` FROM $wpdb->posts WHERE `post_date`<'".date('Y-m-d h:i:s', strtotime("-$prun_period days"))."' AND `post_status`='publish' AND `post_type`='post' LIMIT 10";
	$sql = mysql_query($sql);
	while ($row=mysql_fetch_array($sql)){
		$post_id = (int)$row['ID'];

		if (get_option("prun_status") == "1") {
			$my_post = array();
			$my_post['ID'] = $post_id;
			$my_post['post_status'] = 'draft';
			wp_update_post( $my_post );
		} else if (get_option("prun_status") == "2") {
			wp_delete_post($post_id);
		}
	}
}
?>	
	
<?php get_footer(); ?>