is_main_query() || ! itheme2_featuring_posts() ) return $query; // Exclude featured posts from the main query $query->query_vars['post__not_in'] = itheme2_featuring_posts(); return $query; } add_action( 'pre_get_posts', 'itheme2_home_posts' ); /** * Test to see if any posts meet our conditions for featuring posts. * Current conditions are: * * - sticky posts * - with featured thumbnails * * We store the results of the loop in a transient, to prevent running this * extra query on every page load. The results are an array of post ID's that * match the result above. This gives us a quick way to loop through featured * posts again later without needing to query additional times later. */ function itheme2_featuring_posts( $force_update = false ) { $featured_post_ids = []; if ( $force_update || ( false === ( $featured_post_ids = get_transient( 'featured_post_ids' ) ) ) ) { // Proceed only if sticky posts exist. $sticky = get_option( 'sticky_posts' ); // Proceed only if sticky posts exist. if ( ! empty( $sticky ) && is_array( $sticky ) ) { $featured_args = array( 'post__in' => $sticky, 'post_status' => 'publish', 'no_found_rows' => true, 'ignore_sticky_posts' => true, 'posts_per_page' => 30, ); // The Featured Posts query. $featured = new WP_Query( $featured_args ); // Proceed only if published posts with thumbnails exist if ( $featured->have_posts() ) { while ( $featured->have_posts() ) { $featured->the_post(); if ( '' != get_the_post_thumbnail( $featured->post->ID ) ) { $featured_post_ids[] = $featured->post->ID; } } set_transient( 'featured_post_ids', $featured_post_ids ); } wp_reset_postdata(); } } return $featured_post_ids; } /** * Flush out the transients used in itheme2_featuring_posts() * * @since iTheme2 1.2 */ function itheme2_featured_post_checker_flusher() { // Vvwooshh! delete_transient( 'featured_post_ids' ); } add_action( 'update_option_sticky_posts', 'itheme2_featured_post_checker_flusher' ); add_action( 'save_post', 'itheme2_featured_post_checker_flusher' ); /** * Enqueue scripts and styles */ function itheme2_script_enqueue() { wp_enqueue_style( 'itheme2', get_stylesheet_uri() ); if ( itheme2_featuring_posts() ) wp_enqueue_script( 'jcarousel', get_template_directory_uri() . '/js/jcarousel.js', array( 'jquery' ), false, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); } add_action( 'wp_enqueue_scripts', 'itheme2_script_enqueue' ); function itheme2_footer_scripts() { if ( itheme2_featuring_posts() ) { ?> __( 'Primary Menu', 'itheme2' ), ) ); /** * Add support for Post Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery' ) ); /** * Add support for custom backgrounds */ add_theme_support( 'custom-background' ); /** * Add in support for post thumbnails */ add_theme_support( 'post-thumbnails' ); add_image_size( 'large-feature', 593, 261, true ); // Used for large feature images above the post add_image_size( 'small-feature', 145, 120, true ); // Used for small feature images in the carousel on the home page add_theme_support( 'print-style' ); } endif; // itheme2_setup function itheme2_custom_header_setup() { add_theme_support( 'custom-header', apply_filters( 'itheme2_custom_header_args', array( 'default-image' => '', 'default-text-color' => 'fff', 'random-default' => false, 'width' => 978, 'height' => 288, 'wp-head-callback' => 'itheme2_header_style', 'admin-head-callback' => 'itheme2_admin_header_style', 'admin-preview-callback' => 'itheme2_admin_header_image', ) ) ); } add_action( 'after_setup_theme', 'itheme2_custom_header_setup' ); if ( ! function_exists( 'itheme2_header_style' ) ) : /** * Styles the header image and text displayed on the blog */ function itheme2_header_style() { // If no custom options for text are set, let's bail // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value if ( HEADER_TEXTCOLOR == get_header_textcolor() ) return; // If we get this far, we have custom styles. Let's do this. ?> Header admin panel. * * @since iTheme2 1.0 */ function itheme2_admin_header_style() { ?> Header admin panel. * * @since iTheme2 1.0 */ function itheme2_admin_header_image() { ?>
' . __( 'Continue reading ', 'itheme2' ) . ''; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and itheme2_continue_reading_link(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. */ function itheme2_auto_excerpt_more( $more ) { return ' …' . itheme2_continue_reading_link(); } add_filter( 'excerpt_more', 'itheme2_auto_excerpt_more' ); /** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. */ function itheme2_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= itheme2_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'itheme2_custom_excerpt_more' ); /** * Set a default theme color array for WP.com. */ $themecolors = array( 'bg' => 'ffffff', 'border' => 'eeeeee', 'text' => '444444', ); /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ function itheme2_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'itheme2_page_menu_args' ); /** * Register widgetized area and update sidebar with default widgets */ function itheme2_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar 1', 'itheme2' ), 'id' => 'sidebar-1', 'before_widget' => '", 'before_title' => '