<div class="sub-box-center-viewAll" style="margin-top: 50px;"> <div id="video-holder"> <?php query_posts('category_name=' . get_bloginfo('photos_cat', 'display') . '&showposts=3&paged=' . $this->page); ?> <?php if (have_posts()) { while (have_posts()) { the_post(); global $post; ?> <div style="width:130px; height:200px; overflow:hidden; float:left; padding: 5px 8px;"> <a href=""> <img src="<?php nm_get_photo('130', '100', true, true); ?> " class="photo" alt="photos"> </a> <a href="<?php the_permalink(); ?> "><b><?php the_title(); ?> </b></a><br/> <span class="Spec"> Added: <span class="SpecSource"><?php the_time('jS F'); ?> </span><br/>
$featuredCat = get_bloginfo('home_featured_article', 'display'); $featuredCat = get_category_by_slug($featuredCat); if ($featuredCat) { $featuredPost = get_posts('category=' . $featuredCat->term_id . '&numberposts=1'); } if (empty($featuredPost) || strtotime($featuredPost[0]->post_date) < time() - 1209600) { $articleCat = get_bloginfo('articles_cat', 'display'); $articleCat = get_category_by_slug($articleCat); $featuredPost = get_posts('category=' . $articleCat->term_id . '&numberposts=1&orderby=RAND()'); } setup_postdata($featuredPost[0]); global $post; $post = $featuredPost[0]; $featuredPic = get_post_meta($post->ID, 'featured_image', true); if (empty($featuredPic)) { $featuredPic = nm_get_photo('415', '92', false, false); } else { $featuredPic = get_bloginfo('wpurl') . '/images/phpThumb.php?src=' . wp_make_link_relative($featuredPic) . '&w=415&h=92&zc=C'; } ?> <div class="moduleStatus"> <span>Posted <?php the_time('l, F jS, Y'); ?> at <?php the_time(); ?> </span> </div>
public function nextItem($params) { global $wpdb; $direction = $params['direction']; $postId = $params['postId']; $categoryName = $params['categoryName']; $query = "\n SELECT * FROM\n (\n SELECT\n {$wpdb->posts}.ID,\n (@ROW:=@ROW+1) AS row_current\n FROM (SELECT @ROW:= 0) t, {$wpdb->posts}\n INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)\n INNER JOIN {$wpdb->term_taxonomy}\n ON ({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id)\n INNER JOIN {$wpdb->terms}\n ON ({$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id)\n WHERE\n {$wpdb->posts}.post_type = 'post'\n AND {$wpdb->term_taxonomy}.taxonomy = 'category'\n AND {$wpdb->terms}.slug = '" . $categoryName . "'\n AND ({$wpdb->posts}.post_status = 'publish'\n OR {$wpdb->posts}.post_status = 'private')\n ORDER BY\n {$wpdb->posts}.post_date DESC\n ) AS rowset\n WHERE "; $queryCurrentPosition = $query . " ID = " . intval($postId); $res = $wpdb->get_results($queryCurrentPosition); $result = array(); $title = ""; $content = ""; $image = ""; $time = ""; $link = ""; // next and previous records if (!empty($res)) { $current_position = (int) $res[0]->row_current; $queryNextPrevious = $query . " rowset.row_current = " . ($current_position + 1); if ($current_position > 1) { $queryNextPrevious .= ' OR rowset.row_current = ' . ($current_position - 1); } $res = $wpdb->get_results($queryNextPrevious); if (!empty($res)) { if (count($res) > 1) { $result['previous'] = $res[0]->ID; $result['next'] = $res[1]->ID; } else { if ($direction == "right") { $result['next'] = $res[0]->ID; $result['previous'] = null; } else { $result['next'] = null; $result['previous'] = $res[0]->ID; } } global $post; if ($direction == "right") { if (!is_null($result['next'])) { $query = "SELECT\n {$wpdb->posts}.*\n FROM wp_posts\n WHERE\n {$wpdb->posts}.post_type = 'post'\n AND ({$wpdb->posts}.post_status = 'publish'\n OR {$wpdb->posts}.post_status = 'private')\n AND {$wpdb->posts}.ID = " . $result['next'] . "\n ORDER BY\n {$wpdb->posts}.post_date"; $postNext = $wpdb->get_results($query); if (!empty($postNext)) { $post = $postNext[0]; $title = $post->post_title; $content = get_the_excerpt(); $time = date("d.m.Y", strtotime($post->post_date)); $link = get_permalink(); $image = nm_get_photo(false, false, false, false); } } } elseif ($direction == "left") { if (!is_null($result['previous'])) { $query = "SELECT\n {$wpdb->posts}.*\n FROM wp_posts\n WHERE\n {$wpdb->posts}.post_type = 'post'\n AND ({$wpdb->posts}.post_status = 'publish'\n OR {$wpdb->posts}.post_status = 'private')\n AND {$wpdb->posts}.ID = " . $result['previous'] . "\n ORDER BY\n {$wpdb->posts}.post_date"; $postNext = $wpdb->get_results($query); if (!empty($postNext)) { $post = $postNext[0]; $title = $post->post_title; $content = get_the_excerpt(); $time = date("d.m.Y", strtotime($post->post_date)); $link = get_permalink(); $image = nm_get_photo(false, false, false, false); } } } } } echo json_encode(array('result' => true, 'title' => $title, 'content' => $content, 'time' => $time, 'link' => $link, 'image' => $image, 'nextID' => $result['next'], 'prevID' => $result['previous'])); }