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


PHP get_search_query函数代码示例

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


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

示例1: presscore_search_title_shortcode

 function presscore_search_title_shortcode()
 {
     $title = '';
     $wrap_class = '';
     if (is_search()) {
         $title = get_search_query();
     } else {
         if (is_archive()) {
             if (is_category()) {
                 $title = single_cat_title('', false);
             } elseif (is_tag()) {
                 $title = single_tag_title('', false);
             } elseif (is_author()) {
                 the_post();
                 $title = '<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta("ID"))) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a>';
                 $wrap_class .= ' vcard';
                 rewind_posts();
             } elseif (is_day()) {
                 $title = '<span>' . get_the_date() . '</span>';
             } elseif (is_month()) {
                 $title = '<span>' . get_the_date('F Y');
             } elseif (is_year()) {
                 $title = '<span>' . get_the_date('Y');
             } elseif (is_tax('dt_portfolio_category')) {
                 $title = single_term_title('', false);
             } elseif (is_tax('dt_gallery_category')) {
                 $title = single_term_title('', false);
             }
         }
     }
     if ($title) {
         $title = '<span' . ($wrap_class ? ' class="' . esc_attr($wrap_class) . '"' : '') . '>' . $title . '</span>';
     }
     return $title;
 }
开发者ID:RDePoppe,项目名称:luminaterealestate,代码行数:35,代码来源:shortcode-search-title.php

示例2: uls_get_link

/**
 * Return the HTML link of the translation of a post.
 *
 * @param $post_id integer id of post. If it is null, then it converts the current URL with the language specified.
 * @param $language string language of translation. If it is null or invalid, current language loaded in the page is used.
 * @param $label string inner text of the link.
 * @param $class string text to include as class parameter in the link
 *
 * @return string the HTML link of the translation link of a post.
 */
function uls_get_link($post_id = null, $language = null, $label = null, $class = 'uls-link')
{
    // instance the atribute
    $translation_url = "#";
    if ($post_id == null) {
        if (is_home() || is_front_page() || is_archive() || is_search() || is_author() || is_category() || is_tag() || is_date()) {
            $url = uls_get_browser_url();
            $translation_url = uls_get_url_translated($url, $language);
        } else {
            if (is_search()) {
                $url = get_home_url();
                $url .= "?s=" . get_search_query();
                $translation_url = uls_get_url_translated($url, $language);
            }
        }
    } else {
        $translation_id = uls_get_post_translation_id($post_id, $language);
        if (empty($translation_id)) {
            $translation_id = $post_id;
        }
        //set conversion of permalinks to true
        global $uls_permalink_convertion;
        $uls_permalink_convertion = true;
        $translation_url = uls_get_url_translated(get_permalink($translation_id), $language);
        //reset conversion of permalinks
        $uls_permalink_convertion = false;
        $title = get_the_title($translation_id);
    }
    if (null == $label) {
        return '<a class="' . $class . '" href="' . $translation_url . '" >' . $title . '</a>';
    } else {
        return '<a class="' . $class . '" href="' . $translation_url . '" >' . $label . '</a>';
    }
}
开发者ID:Webilop,项目名称:user-language-switch,代码行数:44,代码来源:uls-functions.php

示例3: mh_page_title

 function mh_page_title()
 {
     if (is_home()) {
         echo get_the_title(get_option('page_for_posts', true));
     } elseif (is_author()) {
         global $author;
         $user_info = get_userdata($author);
         echo __('Articles by ', 'mh') . esc_attr($user_info->display_name);
     } elseif (is_category() || is_tax()) {
         echo single_cat_title("", false);
     } elseif (is_tag()) {
         echo single_tag_title("", false);
     } elseif (is_search()) {
         echo __('Search Results for ', 'mh') . get_search_query();
     } elseif (is_day()) {
         echo get_the_date();
     } elseif (is_month()) {
         echo get_the_date('F Y');
     } elseif (is_year()) {
         echo get_the_date('Y');
     } elseif (is_404()) {
         echo __('Page not found (404)', 'mh');
     } else {
         echo get_the_title();
     }
 }
开发者ID:davidHuanghw,项目名称:david_blog,代码行数:26,代码来源:mh-custom-functions.php

示例4: ikaros_filter_wp_title

function ikaros_filter_wp_title($title, $separator)
{
    if (is_feed()) {
        return $title;
    }
    global $paged, $page;
    if (is_search()) {
        //If we're a search, let's start over:
        $title = sprintf(__('Search results for %s', 'ikaros'), '"' . get_search_query() . '"');
        //Add a page number if we're on page 2 or more:
        if ($paged >= 2) {
            $title .= " {$separator} " . sprintf(__('Page %s', 'ikaros'), $paged);
        }
        //Add the site name to the end:
        $title .= " {$separator} " . get_bloginfo('name', 'display');
        //We're done. Let's send the new title back to wp_title():
        return $title;
    }
    //Otherwise, let's start by adding the site name to the end:
    $title .= get_bloginfo('name', 'display');
    //If we have a site description and we're on the home/front page, add the description:
    $site_description = get_bloginfo('description', 'display');
    if ($site_description && (is_home() || is_front_page())) {
        $title .= " {$separator} " . $site_description;
    }
    //Add a page number if necessary:
    if ($paged >= 2 || $page >= 2) {
        $title .= " {$separator} " . sprintf(__('Page %s', 'ikaros'), max($paged, $page));
    }
    //Return the new title to wp_title():
    return $title;
}
开发者ID:ConceptHaus,项目名称:huasca,代码行数:32,代码来源:functions.php

示例5: wptouch_theme_archive_text

function wptouch_theme_archive_text()
{
    if (!is_home()) {
        echo '<div class="archive-text">';
    }
    if (is_search()) {
        echo sprintf(__("Search results &rsaquo; %s", "wptouch-pro"), get_search_query());
    }
    if (is_category()) {
        echo sprintf(__("Categories &rsaquo; %s", "wptouch-pro"), single_cat_title("", false));
    } elseif (is_tag()) {
        echo sprintf(__("Tags &rsaquo; %s", "wptouch-pro"), single_tag_title(" ", false));
    } elseif (is_day()) {
        echo sprintf(__("Archives &rsaquo; %s", "wptouch-pro"), get_the_time('F jS, Y'));
    } elseif (is_month()) {
        echo sprintf(__("Archives &rsaquo; %s", "wptouch-pro"), get_the_time('F, Y'));
    } elseif (is_year()) {
        echo sprintf(__("Archives &rsaquo; %s", "wptouch-pro"), get_the_time('Y'));
    } elseif (is_404()) {
        echo __("404 Not Found", "wptouch-pro");
    }
    if (!is_home()) {
        echo '</div>';
    }
}
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:25,代码来源:functions.php

示例6: bootswatch_get_search_form

/**
 * Generates Bootstrap powered WordPress compatible search form.
 *
 * @return String       Form HTML.
 */
function bootswatch_get_search_form()
{
    ob_start();
    ?>
	<form role="search" method="get" class="search-form" action="<?php 
    echo esc_url(home_url());
    ?>
">
		<div class="input-group">
			<input class="form-control" name="s" value="<?php 
    echo get_search_query();
    ?>
">
			<span class="input-group-btn">
				<button type="submit" class="btn btn-default">
					<span class="glyphicon glyphicon-search"></span>
					<span class="screen-reader-text"><?php 
    esc_html_e('Search', 'bootswatch');
    ?>
</span>
				</button>
			</span>
		</div>
	</form>
	<?php 
    $form = ob_get_clean();
    return $form;
}
开发者ID:kadimi,项目名称:bootswatch,代码行数:33,代码来源:search-form.php

示例7: tarski_doctitle

/**
 * Returns the document title.
 *
 * The order (site name first or last) can be set on the Tarski Options page.
 * While the function ultimately returns a string, please note that filters
 * are applied to an array! This allows plugins to easily alter any aspect
 * of the title. For example, one might write a plugin to change the separator.
 *
 * @since 1.5
 * @deprecated 3.2.0
 *
 * @param string $sep
 * @return string
 *
 * @hook filter tarski_doctitle
 * Filter document titles.
 */
function tarski_doctitle($sep = '&middot;')
{
    _deprecated_function('wp_title', '3.2.0');
    $site_name = get_bloginfo('name');
    $content = trim(wp_title('', false));
    if (is_404()) {
        $content = sprintf(__('Error %s', 'tarski'), '404');
    } elseif (get_option('show_on_front') == 'posts' && is_home()) {
        $content = get_bloginfo('description', 'display');
    } elseif (is_search()) {
        $content = sprintf(__('Search results for %s', 'tarski'), esc_html(get_search_query()));
    } elseif (is_month()) {
        $content = single_month_title(' ', false);
    } elseif (is_tag()) {
        $content = multiple_tag_titles();
    }
    $elements = strlen($content) > 0 ? array('site_name' => $site_name, 'separator' => $sep, 'content' => $content) : array('site_name' => $site_name);
    if (get_tarski_option('swap_title_order')) {
        $elements = array_reverse($elements, true);
    }
    // Filters should return an array
    $elements = apply_filters('tarski_doctitle', $elements);
    // But if they don't, it won't try to implode
    if (is_array($elements)) {
        $doctitle = implode(' ', $elements);
    }
    echo $doctitle;
}
开发者ID:aleksking,项目名称:sherrill,代码行数:45,代码来源:deprecated.php

示例8: add_head

 function add_head()
 {
     $query = attribute_escape(get_search_query());
     if (strlen($query) > 0) {
         echo '<script type="text/javascript">var hls_query  = "' . $query . '";</script>';
     }
 }
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:7,代码来源:default-extensions.php

示例9: ubik_search_form

function ubik_search_form($html)
{
    global $ubik_search_form_counter;
    // Helper text used throughout the form
    $help = apply_filters('ubik_search_form_text', __('Search', 'ubik'));
    // Generate a unique ID for this search form
    $id = 's-' . uniqid();
    // Accessibility text
    $label = '<label for="' . $id . '" class="screen-reader-text">' . $help . '</label>';
    // Smarter default search form value
    $value = '';
    if (is_search()) {
        $value = 'value="' . esc_attr(get_search_query()) . '"';
    }
    // Search field
    $input = '<input id="' . $id . '" name="s" type="search" class="search-field" placeholder="' . $help . '&hellip;" title="' . $help . '" ' . $value . '/>';
    // Search button (with customizable contents)
    $button = '<button type="submit" class="search-submit">' . apply_filters('ubik_search_button', __('Search', 'ubik')) . '</button>';
    // Assemble form contents; the "reverse" style places a wrapper around the search field and submit button to allow for flex-width search forms
    if (UBIK_SEARCH_FORM_REVERSE) {
        $contents = $button . '<div class="search-field-wrap">' . $input . '</div>';
    } else {
        $contents = $input . $button;
    }
    // Wrap it all up and return
    return '<form role="search" method="get" class="search-form" action="' . trailingslashit(home_url()) . '">' . $label . $contents . '</form>';
}
开发者ID:synapticism,项目名称:ubik-search,代码行数:27,代码来源:ubik-search-core.php

示例10: _carelib_search_form_get_input

/**
 * Get the search form label.
 *
 * @since  1.0.0
 * @access protected
 * @return string
 */
function _carelib_search_form_get_input()
{
    $id = uniqid('searchform-');
    $label = sprintf('<label id="%1$s-label" for="%1$s" class="screen-reader-text">%2$s</label>', esc_attr($id), esc_attr(apply_filters("{$GLOBALS['carelib_prefix']}_search_form_label", __('Search site', 'carelib'))));
    $input = sprintf('<input type="search" name="s" id="%s" placeholder="%s" autocomplete="off" value="%s" />', esc_attr($id), esc_attr(apply_filters("{$GLOBALS['carelib_prefix']}_search_text", __('Search this website', 'carelib'))), esc_attr(apply_filters('the_search_query', get_search_query() ? get_search_query() : '')));
    return $label . $input;
}
开发者ID:wpsitecare,项目名称:carelib,代码行数:14,代码来源:search-form.php

示例11: boilerplate_title

/**
 * Handle output of page title
 */
function boilerplate_title($post = null)
{
    $queried_object = get_queried_object();
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            return get_the_title(get_option('page_for_posts', true));
        } else {
            return __('Latest Posts', 'boilerplate');
        }
    } elseif (is_archive()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        if ($term && get_query_var('taxonomy') !== 'language') {
            return apply_filters('single_term_title', $term->name);
        } elseif (is_post_type_archive()) {
            return apply_filters('the_title', @$queried_object->labels->name ?: $queried_object->post_title);
        } elseif (is_day()) {
            return sprintf(__('Daily Archives: %s', 'boilerplate'), get_the_date());
        } elseif (is_month()) {
            return sprintf(__('Monthly Archives: %s', 'boilerplate'), get_the_date('F Y'));
        } elseif (is_year()) {
            return sprintf(__('Yearly Archives: %s', 'boilerplate'), get_the_date('Y'));
        } elseif (is_author()) {
            $author = $queried_object;
            return sprintf(__('Author Archives: %s', 'boilerplate'), 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 &ldquo;%s&rdquo;', 'boilerplate'), get_search_query());
    } elseif (is_404()) {
        return __('Not Found', 'boilerplate');
    } else {
        return get_the_title();
    }
}
开发者ID:locomotivemtl,项目名称:wordpress-boilerplate,代码行数:38,代码来源:titles.php

示例12: vossen_jubi_get_search_form

    static function vossen_jubi_get_search_form($echo = true)
    {
        $format = current_theme_supports('html5', 'search-form') ? 'html5' : 'xhtml';
        $format = apply_filters('search_form_format', $format);
        if ('html5' == $format) {
            $form = ' <div class="widget-search"><form role="search" method="get" class="search-form" action="' . esc_url(home_url('/')) . '">
			 <div class="input-group">
			<input type="search" class="form-control search-input" placeholder="' . esc_attr_x('Search &hellip;', 'placeholder') . '" value="' . get_search_query() . '" name="s" title="' . esc_attr_x('Search for:', 'label') . '" />
			<span class="input-group-btn">
                                    <button class="btn btn-default search-button" type="submit">
					<i class="fa fa-search"></i>
                                    </button>
                                </span>
			</div>
			</form></div>';
        } else {
            $form = ' <div class="widget-search"><form role="search" method="get" id="searchform" class="searchform" action="' . esc_url(home_url('/')) . '">
			 <div class="input-group">
			<input type="text" class="form-control search-input" placeholder="' . esc_attr_x('Search &hellip;', 'placeholder') . '" value="' . get_search_query() . '" name="s" id="s" />
			 <span class="input-group-btn">
                                    <button class="btn btn-default search-button" type="submit">
					<i class="fa fa-search"></i>
                                    </button>
                                </span>
			</div>
			</form></div>';
        }
        return $form;
    }
开发者ID:lmacwan,项目名称:BreastPlasticSuregon_WP,代码行数:29,代码来源:OverrideWidgets.php

示例13: _esc_search_widget

function _esc_search_widget($html)
{
    ob_start();
    ?>
    <form role="search" method="get" action="<?php 
    echo esc_url(home_url());
    ?>
" class="search-form form-inline">
		<div class="input-group">
			<input type="text" value="<?php 
    echo get_search_query();
    ?>
" name="s" placeholder="<?php 
    _e('Search on this site', 'wig');
    ?>
" class="form-control" />
			<span class="input-group-btn">
				<button class="btn btn-primary" type="submit">
					<i class="glyphicon glyphicon-search"></i>
				</button>
			</span>
		</div>
    </form>
    <?php 
    return ob_get_clean();
}
开发者ID:jaiweb,项目名称:esolutions-wp-base,代码行数:26,代码来源:bootstrap.php

示例14: widget

    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
            
        <div class="search-widget">
            <form role="search" method="get" action="<?php 
        echo site_url();
        ?>
">
                <fieldset>
                    <input id="s" class="search_input" type="text" name="s" value="<?php 
        get_search_query();
        ?>
"/>
                    <input class="submit" id="searchsubmit" type="submit" value="<?php 
        _e('Search', GETTEXT_DOMAIN);
        ?>
"/>
                </fieldset>
            </form>
        </div>

		<?php 
        echo $after_widget;
    }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:31,代码来源:widget-search.php

示例15: mainPageTitle

 /**
  * You can use this to output a proper title for your page. This handles special cases such as archive page titles,
  * taxonomy archives, etc.
  *
  * @return string A nice page title
  */
 public static function mainPageTitle()
 {
     if (is_home()) {
         if (get_option('page_for_posts', true)) {
             return get_the_title(get_option('page_for_posts', true));
         } else {
             return __('Latest Posts', 'baobab');
         }
     } 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(__('Daily Archives: %s', 'baobab'), get_the_date());
         } elseif (is_month()) {
             return sprintf(__('Monthly Archives: %s', 'baobab'), get_the_date('F Y'));
         } elseif (is_year()) {
             return sprintf(__('Yearly Archives: %s', 'baobab'), get_the_date('Y'));
         } elseif (is_author()) {
             $author = get_queried_object();
             return sprintf(__('Author Archives: %s', 'baobab'), 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', 'baobab'), get_search_query());
     } elseif (is_404()) {
         return __('Not Found', 'baobab');
     } else {
         return get_the_title();
     }
 }
开发者ID:marvinlabs,项目名称:baobab,代码行数:40,代码来源:Posts.php


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