Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Custom code goes below this line. */
- add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
- add_filter( 'use_default_gallery_style', '__return_false' );
- /* Add the Javascript */
- $path = get_stylesheet_directory_uri() .'/js/';
- wp_enqueue_script('post-navigation', $path.'jquery.navigate.js', array('jquery'));
- function catch_that_image() {
- global $post, $posts;
- $first_img = '';
- ob_start();
- ob_end_clean();
- $transformed_content = apply_filters('the_content',$post->post_content);
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $transformed_content, $matches);
- $first_img = $matches [1] [0];
- if(empty($first_img)){ //Defines a default image
- $first_img = "/images/default.jpg";
- }
- return $first_img;
- }
- function pagination($pages = '', $range = 4)
- {
- $showitems = ($range * 2)+1;
- global $paged;
- if(empty($paged)) $paged = 1;
- if($pages == '')
- {
- global $wp_query;
- $pages = $wp_query->max_num_pages;
- if(!$pages)
- {
- $pages = 1;
- }
- }
- if(1 != $pages)
- {
- echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
- if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
- if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>";
- for ($i=1; $i <= $pages; $i++)
- {
- if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
- {
- echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
- }
- }
- if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>";
- if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
- echo "</div>\n";
- }
- }
- function mam_posts_where ($where) {
- global $mam_global_where;
- if ($mam_global_where) $where .= " $mam_global_where";
- return $where;
- }
- add_filter('posts_where','mam_posts_where');
- $posts_per_row = 3;
- $posts_per_page = 15;
- $pageURL = 'http';
- $post_type = 'post';
- if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
- $pageURL .= "://";
- if ($_SERVER["SERVER_PORT"] != "80") {
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
- } else {
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
- }
- $letters = $wpdb->get_col(
- "SELECT DISTINCT LEFT(post_title,1) AS first_letter FROM $wpdb->posts
- WHERE post_type = '$post_type' AND post_status = 'publish'
- ORDER BY first_letter ASC"
- );
- $first_letter = ($_GET['first_letter']) ? $_GET['first_letter'] : $letters[0];
- /* Custom code goes above this line. */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement