function base_getBreadcrumbs() { if (is_404()) { return false; } // Hack to fix breadcrumbs when you're viewing the news home if (is_home()) { $post = new \Timber\Post(get_option('page_for_posts')); } else { global $post; } $breadcrumbs = []; if ($post->post_parent) { $parent_id = $post->post_parent; while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = new \Timber\Post($page->ID); $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); } // Add 'Blog Home' to breadcrumbs if you're on a news post or archive if ((is_single() || is_archive()) && !is_search()) { $breadcrumbs[] = new \Timber\Post(get_option('page_for_posts')); } return $breadcrumbs; }
/** * Filter archives to display one less post per page to account for the .page-title circle */ function spun_limit_posts_per_archive_page() { if (!is_home() && is_archive() || is_search()) { $posts_per_page = intval(get_option('posts_per_page')) - 1; set_query_var('posts_per_page', $posts_per_page); } }
function porto_page_title() { global $porto_settings; $output = ''; if (!is_front_page()) { } elseif (is_home()) { $output .= $porto_settings['blog-title']; } if (is_singular()) { $output .= porto_page_title_leaf(); } else { if (is_post_type_archive()) { if (is_search()) { $output .= porto_page_title_leaf('search'); } else { $output .= porto_page_title_archive(); } } elseif (is_tax() || is_tag() || is_category()) { $html = porto_page_title_leaf('term'); if (is_tag()) { $output .= sprintf(__('Tag - %s', 'porto'), $html); } elseif (is_tax('product_tag')) { $output .= sprintf(__('Product Tag - %s', 'porto'), $html); } else { $output .= $html; } } elseif (is_date()) { if (is_year()) { $output .= porto_page_title_leaf('year'); } elseif (is_month()) { $output .= porto_page_title_leaf('month'); } elseif (is_day()) { $output .= porto_page_title_leaf('day'); } } elseif (is_author()) { $output .= porto_page_title_leaf('author'); } elseif (is_search()) { $output .= porto_page_title_leaf('search'); } elseif (is_404()) { $output .= porto_page_title_leaf('404'); } elseif (class_exists('bbPress') && is_bbpress()) { if (bbp_is_search()) { $output .= porto_page_title_leaf('bbpress_search'); } elseif (bbp_is_single_user()) { $output .= porto_page_title_leaf('bbpress_user'); } else { $output .= porto_page_title_leaf(); } } else { if (is_home() && !is_front_page()) { if (get_option('show_on_front') == 'page') { $output .= get_the_title(get_option('page_for_posts', true)); } else { $output .= $porto_settings['blog-title']; } } } } return apply_filters('porto_page_title', $output); }
/** * Wp in Progress * * @author WPinProgress * * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0) * It is also available at this URL: http://www.gnu.org/licenses/gpl-3.0.txt */ function novalite_get_title() { global $post; $title = get_the_title(); if (!empty($title)) { if (is_home() || is_category() || is_search()) { ?> <h3 class="title"> <a href="<?php echo get_permalink($post->ID); ?> "> <?php echo $title; ?> </a> </h3> <?php } else { ?> <h1 class="title"> <?php echo $title; ?> </h1> <?php } } }
function roots_nice_search_redirect() { if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) { wp_redirect(home_url('/search/' . str_replace(array(' ', '%20'), array('+', '+'), get_query_var('s')))); exit; } }
/** * Handle redirects before content is output - hooked into template_redirect so is_page works **/ function woocommerce_redirects() { global $woocommerce, $wp_query; // When default permalinks are enabled, redirect shop page to post type archive url if (isset($_GET['page_id']) && $_GET['page_id'] > 0 && get_option('permalink_structure') == "" && $_GET['page_id'] == woocommerce_get_page_id('shop')) { wp_safe_redirect(get_post_type_archive_link('product')); exit; } // When on the checkout with an empty cart, redirect to cart page if (is_page(woocommerce_get_page_id('checkout')) && sizeof($woocommerce->cart->get_cart()) == 0) { wp_redirect(get_permalink(woocommerce_get_page_id('cart'))); exit; } // When on pay page with no query string, redirect to checkout if (is_page(woocommerce_get_page_id('pay')) && !isset($_GET['order'])) { wp_redirect(get_permalink(woocommerce_get_page_id('checkout'))); exit; } // My account page redirects (logged out) if (!is_user_logged_in() && (is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')))) { wp_redirect(get_permalink(woocommerce_get_page_id('myaccount'))); exit; } // Redirect to the product page if we have a single product if (is_search() && is_post_type_archive('product') && get_option('woocommerce_redirect_on_single_search_result') == 'yes') { if ($wp_query->post_count == 1) { $product = new WC_Product($wp_query->post->ID); if ($product->is_visible()) { wp_safe_redirect(get_permalink($product->id), 302); } exit; } } }
function wpex_blog_exclude_categories() { // Wait..we don't want to be in these plages? Lets leave now! if (is_admin()) { return; } if (is_search()) { return; } if (is_archive()) { return; } // Categories to exclude $cats_to_exclude = wpex_option('blog_cats_exclude'); // Admin option is blank, so bail. if ($cats_to_exclude == '') { return; } // Blog template if (is_home() && !is_singular('page')) { $exclude = $cats_to_exclude; } else { return; // Do nothing, ok? } if ($cats_to_exclude) { set_query_var('category__not_in', $cats_to_exclude); } }
function insert_wp_about_author($content) { $wp_about_author_settings = array(); $wp_about_author_settings = get_option('wp_about_author_settings'); if (is_front_page() && isset($wp_about_author_settings['wp_author_display_front']) && $wp_about_author_settings['wp_author_display_front']) { $content = $content . wp_about_author_display(); } else { if (is_archive() && isset($wp_about_author_settings['wp_author_display_archives']) && $wp_about_author_settings['wp_author_display_archives']) { $content = $content . wp_about_author_display(); } else { if (is_search() && isset($wp_about_author_settings['wp_author_display_search']) && $wp_about_author_settings['wp_author_display_search']) { $content = $content . wp_about_author_display(); } else { if (is_page() && isset($wp_about_author_settings['wp_author_display_pages']) && $wp_about_author_settings['wp_author_display_pages']) { $content = $content . wp_about_author_display(); } else { if (is_single() && isset($wp_about_author_settings['wp_author_display_posts']) && $wp_about_author_settings['wp_author_display_posts']) { $content = $content . wp_about_author_display(); } else { if (is_feed() && isset($wp_about_author_settings['wp_author_display_feed']) && $wp_about_author_settings['wp_author_display_feed']) { $content = $content . wp_about_author_display(true); } else { $content = $content; } } } } } } return $content; }
/** * Checks if product search screen is active * * @return boolean */ function is_ic_product_search() { if (is_search() && isset($_GET['post_type']) && strpos($_GET['post_type'], 'al_product') !== false) { return true; } return false; }
function description() { if (is_home() || is_front_page()) { echo trim(of_get_option('site_description')); } elseif (is_category()) { $description = strip_tags(category_description()); echo trim($description); } elseif (is_single()) { if (get_the_excerpt()) { echo get_the_excerpt(); } else { global $post; $description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($post->post_content)))); echo mb_substr($description, 0, 220, 'utf-8'); } } elseif (is_search()) { echo '“'; the_search_query(); echo '”为您找到结果 '; global $wp_query; echo $wp_query->found_posts; echo ' 个'; } elseif (is_tag()) { $description = strip_tags(tag_description()); echo trim($description); } else { $description = strip_tags(term_description()); echo trim($description); } }
/** *主文章列表 *http://www.bgbk.org */ function Bing_posts_list() { if (have_posts()) { echo '<ul class="posts-list">'; while (have_posts()) { the_post(); Bing_posts_list_loop(); } echo '</ul>'; Bing_page_navi(array('before' => '<div class="span12 posts-list-page-navi"><div class="panel page-navi">', 'after' => '</div></div>')); Bing_mobile_page_navi(); } else { ?> <div class="empty-posts-list span12"> <article class="panel"> <?php echo '<p>'; if (is_home()) { _e('这里什么都没有', 'Bing'); echo '</p>'; } elseif (is_search()) { _e('没有搜索到任何结果', 'Bing'); echo '</p>'; } else { _e('这里什么都没有,你也许可以使用搜索功能找到你需要的内容:', 'Bing'); echo '</p>'; get_search_form(); } ?> </article> </div> <?php } }
function kobu_post_entry_classes($classes) { // Post Data global $post, $wpex_count; $post_id = $post->ID; $post_type = get_post_type($post_id); // Do nothing for slides if ($post_type == 'slides') { return $classes; } // Search results if (is_search()) { $classes[] = 'search-entry'; if (!has_post_thumbnail()) { $classes[] = 'no-featured-image'; } return $classes; } // Custom class for non standard post types if ($post_type !== 'post') { $classes[] = $post_type . '-entry'; } // Counter if ($wpex_count) { $classes[] = 'count-' . $wpex_count; } // Return classes return $classes; }
/** * Page titles */ function pinnacle_title() { if (is_home()) { if (get_option('page_for_posts', true)) { return get_the_title(get_option('page_for_posts', true)); } else { return __('Latest Posts', 'pinnacle'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { return $term->name; } elseif (is_post_type_archive()) { return get_queried_object()->labels->name; } elseif (is_day()) { return sprintf(__('Daily Archives: %s', 'pinnacle'), get_the_date()); } elseif (is_month()) { return sprintf(__('Monthly Archives: %s', 'pinnacle'), get_the_date('F Y')); } elseif (is_year()) { return sprintf(__('Yearly Archives: %s', 'pinnacle'), get_the_date('Y')); } elseif (is_author()) { return sprintf(__('Author Archives: %s', 'pinnacle'), get_the_author()); } else { return single_cat_title("", false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'pinnacle'), get_search_query()); } elseif (is_404()) { return __('Not Found', 'pinnacle'); } else { return get_the_title(); } }
public function display($options = array()) { $options = array_merge(array('separator' => ' / '), $options); $crumbs = array(); $path = array(); $post = GummRegistry::get('Model', 'Post')->getQueriedObject(); if (is_page() && $post->ID != $this->Wp->getFrontPageId()) { $path = $this->getPathFromNavMenu($post->ID); if (!$path) { $path = $this->getPathFromAncestors($post); } } elseif ($post && is_home()) { $path[] = $this->getNode($post, 'page'); } elseif (is_single()) { $postCategories = $this->Wp->getPostCategories($post); $counter = 1; foreach ($postCategories as $catId => $postCategory) { if ($counter > 4) { break; } $path[] = array('id' => $catId, 'title' => $postCategory, 'url' => $this->Wp->getPostCategoryLink($post, $catId)); $counter++; } $path[] = $this->getNode($post, 'page'); } elseif (is_search()) { $path[] = array('id' => null, 'title' => __('Search', 'gummfw'), 'url' => null); } array_unshift($path, array('id' => $this->Wp->getFrontPageId(), 'title' => __('Home', 'gummfw'), 'url' => home_url())); $path = apply_filters('gumm_breadcrumb_path', $path); foreach ($path as $item) { $crumbs[] = $this->crumb($item); } return implode($options['separator'], $crumbs); }
/** * Gets the page type from WordPress. * * @return string A string representation of the current page type, * corresponding to the values used by publisherplugin.google.com. */ public static function getWordPressPageType() { // is_front_page() returns true if (1) a static front page is set and this // is that page, or (2) the front page is the blog home page and this // is the blog home page. if (is_front_page()) { return 'front'; } if (is_home()) { return 'home'; } if (is_single()) { return 'singlePost'; } if (is_page()) { return 'page'; } if (is_category()) { return 'category'; } if (is_archive()) { return 'archive'; } if (is_search()) { return 'search'; } if (is_404()) { return 'errorPage'; } return ''; }
function widget($args, $widget_args = 1) { extract($args); global $post; global $id; if (is_search()) { return; } if (is_numeric($widget_args)) { $widget_args = array('number' => $widget_args); } $widget_args = wp_parse_args($widget_args, array('number' => -1)); extract($widget_args, EXTR_SKIP); $options_all = get_option('widget_df_subpages'); if (!isset($options_all[$number])) { return; } $options = $options_all[$number]; //get breadcrumb list $this_page = $id; $this_page_post = get_post($this_page); $breadcrumb[] = $this_page; $parent_id = $this_page_post->post_parent; $bc_parent_id = $this_page_post->post_parent; while ($bc_parent_id != 0) { $breadcrumb[] = $bc_parent_id; $bc_parent = get_post($bc_parent_id); $bc_parent_id = $bc_parent->post_parent; } $breadcrumb_levels = array_reverse($breadcrumb, false); //display $this->nav_level(0, $breadcrumb_levels, $id, $parent_id, $before_widget, $after_widget, $options); }
/** * The WP functions and definitions * * @package The WP Theme */ function my_posy_search($search) { if (is_search()) { $search .= " AND post_type = 'post'"; } return $search; }
/** * Page titles */ function roots_title() { if (is_home()) { if (get_option('page_for_posts', true)) { return get_the_title(get_option('page_for_posts', true)); } else { return __('Most Recent Posts', 'roots'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { return apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { return apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { return sprintf(__('Old Posts, Organized by Day: %s', 'roots'), get_the_date()); } elseif (is_month()) { return sprintf(__('Old Posts, Organized by Month: %s', 'roots'), get_the_date('F Y')); } elseif (is_year()) { return sprintf(__('Old Posts, Organized by Year: %s', 'roots'), get_the_date('Y')); } elseif (is_author()) { $author = get_queried_object(); return sprintf(__('Old Posts, Organized by Author: %s', 'roots'), apply_filters('the_author', is_object($author) ? $author->display_name : null)); } else { return single_cat_title('', false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'roots'), get_search_query()); } elseif (is_404()) { return __('Not Found', 'roots'); } else { return get_the_title(); } }
function widget($args, $instance) { global $wp_query; $facets = elasticsearch\Faceting::all(); $url = null; if (is_category() || is_tax()) { $url = get_term_link($wp_query->queried_object); } elseif (is_tag()) { $url = get_tag_link($wp_query->queried_object->term_id); } elseif (is_archive()) { $url = get_post_type_archive_link($wp_query->queried_object->query_var); } elseif (is_search()) { $url = home_url('/'); } foreach ($facets as $type => $facet) { if (count($facet['selected']) > 0) { $name = $type; if (taxonomy_exists($type)) { $name = get_taxonomy($type)->label; } echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">'; echo '<h3 class="widget-title">' . $name . '</h3>'; echo '<ul>'; foreach ($facet['selected'] as $option) { $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']); echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">'; echo '<a href="' . $url . '">' . $option['name'] . '</a>'; echo '</li>'; } echo '</ul>'; echo '</aside>'; } } }
/** * Enqueues scripts and styles for front-end. * */ function galanight_scripts_styles() { global $wp_styles, $wp_scripts, $galanight_options_db; // Adds JavaScript if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } if ($galanight_options_db['galanight_infinite_scroll'] != 'Disable') { if (is_home() || is_archive() || is_search()) { wp_enqueue_script('galanight-infinitescroll', get_template_directory_uri() . '/js/infinitescroll.js', array('jquery'), '2.0.2', true); wp_enqueue_script('galanight-infinitescroll-settings', get_template_directory_uri() . '/js/infinitescroll-settings.js', array(), '1.0', true); $galanight_site_parameters = array('theme_directory' => get_template_directory_uri(), 'message_load' => __('<p>Loading...</p>', 'galanight'), 'message_end' => __('<p>No further posts.</p>', 'galanight')); wp_localize_script('galanight-infinitescroll-settings', 'SiteParameters', $galanight_site_parameters); } } wp_enqueue_script('galanight-placeholders', get_template_directory_uri() . '/js/placeholders.js', array('jquery'), '2.0.8', true); if ($galanight_options_db['galanight_display_scroll_top'] != 'Hide') { wp_enqueue_script('galanight-scroll-to-top', get_template_directory_uri() . '/js/scroll-to-top.js', array('jquery'), '1.0', true); } if (has_nav_menu('main-navigation') && $galanight_options_db['galanight_header_layout'] == 'Centered' && !is_page_template('template-landing-page.php')) { wp_enqueue_script('galanight-menubox', get_template_directory_uri() . '/js/menubox.js', array(), '1.0', true); } wp_enqueue_script('galanight-selectnav', get_template_directory_uri() . '/js/selectnav.js', array(), '0.1', true); wp_enqueue_script('galanight-responsive', get_template_directory_uri() . '/js/responsive.js', array(), '1.0', true); wp_enqueue_script('galanight-html5-ie', get_template_directory_uri() . '/js/html5.js', array(), '3.6', false); $wp_scripts->add_data('galanight-html5-ie', 'conditional', 'lt IE 9'); // Adds CSS wp_enqueue_style('galanight-elegantfont', get_template_directory_uri() . '/css/elegantfont.css'); wp_enqueue_style('galanight-google-font-default', '//fonts.googleapis.com/css?family=Oswald&subset=latin,latin-ext'); if (class_exists('woocommerce')) { wp_enqueue_style('galanight-woocommerce-custom', get_template_directory_uri() . '/css/woocommerce-custom.css'); } }
function blog_summary_shortcode($attr) { // Describes what attributes to parse from shortcode; only 'count' extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr)); // Queries to populate our loop based on shortcode count attribute $r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish"); // Only run if we have posts; can't run this through searches if ($r->have_posts() && !is_search()) { // If we're using a Sandbox-friendly theme . . . if (function_exists('sandbox_body_class')) { // We can't have double hfeed classes, otherwise it won't parse $groupclasses = 'xoxo'; } else { // Otherwise, use hfeed to ensure hAtom compliance $groupclasses = 'xoxo hfeed'; } // Begin the output for shortcode and inserts in the group tag what classes we have $output = '<' . $grouptag . ' class="' . $groupclasses . '">'; // Begins our loop for returning posts while ($r->have_posts()) { // Sets which post from our loop we're at $r->the_post(); // Allows the_date() with multiple posts within a single day unset($previousday); // If we're using a Sandbox-friendly theme . . . if (function_exists('sandbox_post_class')) { // Let's use semantic classes with each entry element $entryclasses = sandbox_post_class(false); } else { // Otherwise, use hentry to ensure hAtom compliance $entryclasses = 'hentry'; } // Begin entry wrapper and inserts what classes we got from above $output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">'; // Post title $output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>'; // Post date with hAtom support $output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>'; // Comments number $output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>'; // Post excerpt with hAtom support $output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>'; // Close each post LI $output .= "\n" . '</' . $entrytag . '>'; // Finish the have_posts() query } // while ( $r->have_posts() ) : // Close the parent UL $output .= "\n" . '</' . $grouptag . '>'; // Rewinds loop from $r->the_post(); rewind_posts(); // End the initial IF statement } // if ( $r->have_posts() ) : // Clears our query to put the loop back where it was wp_reset_query(); // $r = new WP_Query() // Returns $output to the shortcode return $output; }
function pl_posts_404() { $head = __('Nothing Found', 'pagelines'); $subhead = is_search() ? __('Try another search?', 'pagelines') : __("Sorry, what you are looking for isn't here.", 'pagelines'); $the_text = sprintf('<h2 class="center">%s</h2><p class="subhead center">%s</p>', $head, $subhead); return sprintf('<section class="billboard">%s <div class="center fix">%s</div></section>', apply_filters('pagelines_posts_404', $the_text), pagelines_search_form(false)); }
function gdl_custom_search_query($query) { global $gdl_search_package; if (is_search() && $query->is_main_query() && isset($_GET['posttype']) && $_GET['posttype'] == 'package') { $gdl_search_package = true; $meta_query = array('relation' => 'AND'); if (isset($_GET['location'])) { array_push($meta_query, array('key' => 'package-location', 'value' => $_GET['location'], 'compare' => 'LIKE')); } if (isset($_GET['package-type'])) { $query->query_vars['package-tag'] = $_GET['package-type']; } if (isset($_GET['departure-date'])) { array_push($meta_query, array('key' => 'package-start-date', 'value' => $_GET['departure-date'], 'compare' => '=')); } if (isset($_GET['arrival-date'])) { array_push($meta_query, array('key' => 'package-end-date', 'value' => $_GET['arrival-date'], 'compare' => '=')); } if (isset($_GET['max-budget'])) { array_push($meta_query, array('key' => 'package-min-price', 'value' => $_GET['max-budget'], 'compare' => '<=', 'type' => 'DECIMAL')); } $query->set('meta_query', $meta_query); $query->query_vars['post_type'] = 'package'; } }
function product_search_sku($where) { global $pagenow, $wpdb, $wp; //VAR_DUMP(http_build_query(array('post_type' => array('product','boobs'))));die(); $type = array('product', 'jam'); //var_dump(in_array('product', $wp->query_vars['post_type'])); if (is_admin() && 'edit.php' != $pagenow || !is_search() || !isset($wp->query_vars['s']) || isset($wp->query_vars['post_type']) && 'product' != $wp->query_vars['post_type'] || isset($wp->query_vars['post_type']) && is_array($wp->query_vars['post_type']) && !in_array('product', $wp->query_vars['post_type'])) { return $where; } $search_ids = array(); $terms = explode(',', $wp->query_vars['s']); foreach ($terms as $term) { //Include the search by id if admin area. if (is_admin() && is_numeric($term)) { $search_ids[] = $term; } // search for variations with a matching sku and return the parent. $sku_to_parent_id = $wpdb->get_col($wpdb->prepare("SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key='_sku' and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean($term))); //Search for a regular product that matches the sku. $sku_to_id = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value LIKE '%%%s%%';", wc_clean($term))); $search_ids = array_merge($search_ids, $sku_to_id, $sku_to_parent_id); } $search_ids = array_filter(array_map('absint', $search_ids)); if (sizeof($search_ids) > 0) { $where = str_replace(')))', ") OR ({$wpdb->posts}.ID IN (" . implode(',', $search_ids) . "))))", $where); } remove_filters_for_anonymous_class('posts_search', 'WC_Admin_Post_Types', 'product_search', 10); return $where; }
function the_content($content) { global $post, $EM_Event; if ($post->post_type == EM_POST_TYPE_EVENT) { if (is_archive() || is_search()) { if (get_option('dbem_cp_events_archive_formats')) { $EM_Event = em_get_event($post); $content = $EM_Event->output(get_option('dbem_event_list_item_format')); } } else { if (get_option('dbem_cp_events_formats') && !post_password_required()) { $EM_Event = em_get_event($post); ob_start(); em_locate_template('templates/event-single.php', true); $content = ob_get_clean(); } else { $EM_Event = em_get_event($post); if ($EM_Event->event_rsvp) { $content .= $EM_Event->output('<h2>Bookings</h2>#_BOOKINGFORM'); } } } } return $content; }
function featureText() { if (is_front_page()) { the_field('feature_text'); } elseif (is_home() || is_single()) { _e('Rock Theme Official Blog'); } elseif (is_archive()) { _e('Rock Theme Official Blog'); _e('<br>'); single_term_title('Browsing: '); if (is_month()) { $monthNum = get_query_var('monthnum'); $month = date('F', mktime(0, 0, 0, $monthNum)); $year = get_query_var('year'); echo 'Posts from ' . $month . ' ' . $year; } } elseif (is_page_template('page-news.php') || is_page_template('page-about.php') || is_page_template('page-contact.php')) { bloginfo('name'); _e('<br>'); the_title(); } elseif (is_404()) { _e('Whoops, were a little lost.'); } elseif (is_search()) { _e('Rock Theme Official Blog'); _e('<br>'); printf('Search results for: %s', get_search_query()); } }
/** * Page titles */ function stachestack_title() { if (is_home()) { if (get_option('page_for_posts', true)) { $title = get_the_title(get_option('page_for_posts', true)); } else { $title = __('Latest Posts', 'stachestack'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { $title = apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { $title = apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { $title = sprintf(__('Daily Archives: %s', 'stachestack'), get_the_date()); } elseif (is_month()) { $title = sprintf(__('Monthly Archives: %s', 'stachestack'), get_the_date('F Y')); } elseif (is_year()) { $title = sprintf(__('Yearly Archives: %s', 'stachestack'), get_the_date('Y')); } elseif (is_author()) { $title = sprintf(__('Author Archives: %s', 'stachestack'), get_queried_object()->display_name); } else { $title = single_cat_title('', false); } } elseif (is_search()) { $title = sprintf(__('Search Results for %s', 'stachestack'), get_search_query()); } elseif (is_404()) { $title = __('Not Found', 'stachestack'); } else { $title = get_the_title(); } return apply_filters('stachestack_title', $title); }
/** * tarski_posts_nav_link() - Outputs next / previous index page links. * * @since 1.2 * @global object $wp_query * @return string */ function tarski_posts_nav_link() { if (get_tarski_option('use_pages')) { global $wp_query; if (!is_singular()) { $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var('paged'); $sep = ' § '; // Only have sep if there's both prev and next results if ($paged < 2 || $paged >= $max_num_pages) { $sep = ''; } if ($max_num_pages > 1) { echo '<p class="pagination">'; if (is_search()) { previous_posts_link('« ' . __('Previous results', 'tarski')); echo $sep; next_posts_link(__('More results', 'tarski') . ' »'); } else { next_posts_link('« ' . __('Older entries', 'tarski')); echo $sep; previous_posts_link(__('Newer entries', 'tarski') . ' »'); } echo "</p>\n"; } } } }
/** * Prints HTML with meta information for the current post-date/time, author, comment count and categories. */ function ultra_posted_on() { echo '<div class="entry-meta-inner">'; if (is_sticky() && is_home() && !is_paged()) { echo '<span class="featured-post">' . __('Sticky', 'ultra') . '</span>'; } if (is_home() && siteorigin_setting('blog_post_date') || is_archive() && siteorigin_setting('blog_post_date') || is_search() && siteorigin_setting('blog_post_date')) { echo '<span class="entry-date"><a href="' . esc_url(get_permalink()) . '" rel="bookmark"><time class="published" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html(get_the_date('j F Y')) . '</time><time class="updated" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html(get_the_modified_date()) . '</time></span></a>'; } if (is_single() && siteorigin_setting('blog_post_date')) { echo '<span class="entry-date"><time class="published" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html(get_the_date('j F Y')) . '</time><time class="updated" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html(get_the_modified_date()) . '</time></span>'; } if (siteorigin_setting('blog_post_author')) { echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author">' . esc_html(get_the_author()) . '</a></span></span>'; } if (comments_open() && siteorigin_setting('blog_post_comment_count')) { echo '<span class="comments-link">'; comments_popup_link(__('Leave a comment', 'ultra'), __('1 Comment', 'ultra'), __('% Comments', 'ultra')); echo '</span>'; } echo '</div>'; if (is_single() && siteorigin_setting('navigation_post_nav')) { the_post_navigation($args = array('prev_text' => '', 'next_text' => '')); } }
/** * Enqueues scripts and styles for front-end. * */ function shootingstar_scripts_styles() { global $wp_styles, $wp_scripts; // Adds JavaScript if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } if (get_theme_mod('shootingstar_infinite_scroll') != 'Disable') { if (is_home() || is_archive() || is_search()) { wp_enqueue_script('shootingstar-infinitescroll', get_template_directory_uri() . '/js/infinitescroll.min.js', array('jquery'), '2.0.2', true); wp_enqueue_script('shootingstar-infinitescroll-settings', get_template_directory_uri() . '/js/infinitescroll-settings.js', array(), '1.0', true); $shootingstar_site_parameters = array('theme_directory' => get_template_directory_uri(), 'message_load' => __('<p>Loading...</p>', 'shootingstar'), 'message_end' => __('<p>No further posts.</p>', 'shootingstar')); wp_localize_script('shootingstar-infinitescroll-settings', 'SiteParameters', $shootingstar_site_parameters); } } wp_enqueue_script('shootingstar-placeholders', get_template_directory_uri() . '/js/placeholders.js', array('jquery'), '2.0.8', true); if (get_theme_mod('shootingstar_display_scroll_top') != 'Hide') { wp_enqueue_script('shootingstar-scroll-to-top', get_template_directory_uri() . '/js/scroll-to-top.js', array('jquery'), '1.0', true); } if (get_theme_mod('shootingstar_fixed_menu') != 'Disable' && !is_page_template('template-landing-page.php')) { wp_enqueue_script('shootingstar-menubox', get_template_directory_uri() . '/js/menubox.js', array(), '1.0', true); } wp_enqueue_script('shootingstar-selectnav', get_template_directory_uri() . '/js/selectnav.js', array(), '0.1', true); wp_enqueue_script('shootingstar-responsive', get_template_directory_uri() . '/js/responsive.js', array(), '1.0', true); wp_enqueue_script('shootingstar-html5-ie', get_template_directory_uri() . '/js/html5.min.js', array(), '3.7.2', false); $wp_scripts->add_data('shootingstar-html5-ie', 'conditional', 'lt IE 9'); // Adds CSS wp_enqueue_style('shootingstar-elegantfont', get_template_directory_uri() . '/css/elegantfont.css'); wp_enqueue_style('shootingstar-google-font-default', '//fonts.googleapis.com/css?family=PT+Sans&subset=latin,latin-ext'); if (class_exists('woocommerce')) { wp_enqueue_style('shootingstar-woocommerce-custom', get_template_directory_uri() . '/css/woocommerce-custom.css'); } }