当前位置: 首页>>代码示例>>PHP>>正文


PHP is_search函数代码示例

本文整理汇总了PHP中is_search函数的典型用法代码示例。如果您正苦于以下问题:PHP is_search函数的具体用法?PHP is_search怎么用?PHP is_search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_search函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: base_getBreadcrumbs

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;
}
开发者ID:wearebase,项目名称:web-wordpress,代码行数:27,代码来源:breadcrumbs.php

示例2: spun_limit_posts_per_archive_page

/**
 * 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);
    }
}
开发者ID:sudocoda,项目名称:ekiben,代码行数:10,代码来源:extras.php

示例3: porto_page_title

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);
}
开发者ID:booklein,项目名称:wpbookle,代码行数:60,代码来源:page-title.php

示例4: novalite_get_title

/**
 * 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 
        }
    }
}
开发者ID:f0rg3,项目名称:salvation-army,代码行数:37,代码来源:title.php

示例5: roots_nice_search_redirect

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;
    }
}
开发者ID:herrhaase,项目名称:roots,代码行数:7,代码来源:roots-cleanup.php

示例6: woocommerce_redirects

/**
 * 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;
        }
    }
}
开发者ID:eddiewilson,项目名称:new-ke,代码行数:37,代码来源:woocommerce-functions.php

示例7: wpex_blog_exclude_categories

 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);
     }
 }
开发者ID:nhatnam1102,项目名称:wp-content,代码行数:29,代码来源:blog-exclude-categories.php

示例8: insert_wp_about_author

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;
}
开发者ID:revathskumar,项目名称:Coderepo,代码行数:31,代码来源:wp-about-author.php

示例9: is_ic_product_search

/**
 * 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;
}
开发者ID:nanookYs,项目名称:orientreizen,代码行数:12,代码来源:conditionals.php

示例10: description

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);
    }
}
开发者ID:carpliyz,项目名称:9IPHP,代码行数:30,代码来源:header.php

示例11: Bing_posts_list

/**
	*主文章列表
	*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 
    }
}
开发者ID:w392807287,项目名称:FirstRepository,代码行数:38,代码来源:posts-list.php

示例12: kobu_post_entry_classes

 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;
 }
开发者ID:kobuagency,项目名称:wp-kobu-starter,代码行数:29,代码来源:post-classes.php

示例13: pinnacle_title

/**
 * 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();
    }
}
开发者ID:aliaspseudonym,项目名称:MoonCatCreations,代码行数:36,代码来源:utils.php

示例14: display

 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);
 }
开发者ID:nikolaskarica,项目名称:bds-alliance,代码行数:34,代码来源:breadcrumb.php

示例15: getWordPressPageType

 /**
  * 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 '';
 }
开发者ID:thabofletcher,项目名称:tc-site,代码行数:37,代码来源:Utils.php


注:本文中的is_search函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。