本文整理汇总了PHP中wp_title函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_title函数的具体用法?PHP wp_title怎么用?PHP wp_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_title函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: title
function title()
{
if (is_category()) {
echo 'Category Archive for "';
single_cat_title();
echo '" | ';
bloginfo('name');
} elseif (is_tag()) {
echo 'Tag Archive for "';
single_tag_title();
echo '" | ';
bloginfo('name');
} elseif (is_archive()) {
wp_title('');
echo ' Archive | ';
bloginfo('name');
} elseif (is_search()) {
echo 'Search for "' . wp_specialchars($s) . '" | ';
bloginfo('name');
} elseif (is_home() || is_front_page()) {
bloginfo('name');
echo ' | ';
bloginfo('description');
} elseif (is_404()) {
echo 'Error 404 Not Found | ';
bloginfo('name');
} elseif (is_single()) {
wp_title('');
} else {
echo wp_title(' | ', false, right);
bloginfo('name');
}
}
示例2: theme_description
function theme_description()
{
global $s, $post;
$description = '';
$blog_name = get_bloginfo('name');
if (is_singular()) {
if (!empty($post->post_excerpt)) {
$text = $post->post_excerpt;
} else {
$text = $post->post_content;
}
$description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($text))));
if (!$description) {
$description = $blog_name . "-" . trim(wp_title('', false));
}
} elseif (is_home()) {
$description = $blog_name . "-" . get_bloginfo('description') . '|' . dopt('Rcloud_description');
// 首頁要自己加
} elseif (is_tag()) {
$description = $blog_name . "有关 '" . single_tag_title('', false) . "' 的文章";
} elseif (is_category()) {
$description = $blog_name . "有关 '" . single_cat_title('', false) . "' 的文章";
} elseif (is_archive()) {
$description = $blog_name . "在: '" . trim(wp_title('', false)) . "' 的文章";
} elseif (is_search()) {
$description = $blog_name . ": '" . esc_html($s, 1) . "' 的搜索結果";
} else {
$description = $blog_name . "有关 '" . trim(wp_title('', false)) . "' 的文章";
}
$description = mb_substr($description, 0, 220, 'utf-8') . '..';
echo "<meta name=\"description\" content=\"{$description}\" />\n";
}
示例3: get_wp_title_rss
/**
* Retrieve the blog title for the feed title.
*
* @package WordPress
* @subpackage Feed
* @since 2.2.0
* @uses apply_filters() Calls 'get_wp_title_rss' hook on title.
* @uses wp_title() See function for $sep parameter usage.
*
* @param string $sep Optional.How to separate the title. See wp_title() for more info.
* @return string Error message on failure or blog title on success.
*/
function get_wp_title_rss($sep = '»') {
$title = wp_title($sep, false);
if ( is_wp_error( $title ) )
return $title->get_error_message();
$title = apply_filters('get_wp_title_rss', $title);
return $title;
}
示例4: df_page_title
/**
* Output the site page title
* @access public
* @subpackage Framework/Head
* @return void
*/
function df_page_title($title)
{
$title = '<title>' . get_bloginfo('name') . ' | ';
$title .= is_home() ? get_bloginfo('description') : wp_title('', false);
$title .= '</title>';
echo apply_filters('df_page_title', $title);
}
示例5: wp_head
public function wp_head()
{
if (is_question()) {
global $wp;
echo '<link href="' . home_url(add_query_arg(array(), $wp->request)) . '" title="' . wp_title('|', false, 'right') . '" type="application/rss+xml" rel="alternate">';
}
}
示例6: rt_breadcrumb
function rt_breadcrumb($gecerli_sayfa)
{
if (is_page()) {
$ust_id = $gecerli_sayfa->post_parent;
$yeni_sorgu = get_post($ust_id);
if ($yeni_sorgu->post_parent) {
rt_breadcrumb($yeni_sorgu);
echo " \\ ";
}
echo "<a href=\"" . get_permalink($yeni_sorgu->ID) . "\" title=\"\" >" . get_the_title($yeni_sorgu->ID) . "</a>";
} elseif (is_single() || is_category() && !is_archive()) {
$ust_id = $gecerli_sayfa->post_parent;
$yeni_sorgu = get_post($ust_id);
$kategori = get_the_category($yeni_sorgu->ID);
$ID = $kategori[0]->cat_ID;
$ayrac = " \ ";
echo get_category_parents($ID, TRUE, $ayrac, FALSE);
if ($yeni_sorgu->post_parent) {
rt_breadcrumb($yeni_sorgu);
if (!is_category()) {
echo " \\ ";
}
}
if (is_single()) {
echo "<a href=\"" . get_permalink($yeni_sorgu->ID) . "\" title=\"\" >" . get_the_title($yeni_sorgu->ID) . "</a>";
}
} else {
echo wp_title('');
}
}
示例7: reactor_do_reactor_head
/**
* Site meta, title, and favicon
* in header.php
*
* @since 1.0.0
*/
function reactor_do_reactor_head()
{
?>
<meta charset="<?php
bloginfo('charset');
?>
" />
<title><?php
wp_title('|', true, 'right');
?>
</title>
<!-- google chrome frame for ie -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- mobile meta -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<?php
$favicon_uri = reactor_option('favicon_image') ? reactor_option('favicon_image') : get_template_directory_uri() . '/favicon.ico';
?>
<link rel="shortcut icon" href="<?php
echo $favicon_uri;
?>
">
<link rel="pingback" href="<?php
bloginfo('pingback_url');
?>
">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>
<?php
}
示例8: A2A_SHARE_SAVE_link_vars
function A2A_SHARE_SAVE_link_vars($linkname = false, $linkurl = false, $linkmedia = false, $use_current_page = false)
{
global $post;
// Set linkname
if (!$linkname) {
if ($use_current_page) {
$linkname = is_home() || is_front_page() ? get_bloginfo('name') : rtrim(wp_title('', false, 'right'));
} elseif (isset($post)) {
$linkname = html_entity_decode(strip_tags(get_the_title($post->ID)), ENT_QUOTES, 'UTF-8');
} else {
$linkname = '';
}
}
$linkname_enc = rawurlencode($linkname);
// Set linkurl
if (!$linkurl) {
if ($use_current_page) {
$linkurl = esc_url_raw((is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
} elseif (isset($post)) {
$linkurl = get_permalink($post->ID);
} else {
$linkurl = '';
}
}
$linkurl_enc = rawurlencode($linkurl);
// Set linkmedia (only applies to services that explicitly accept media; Pinterest does, most do not)
$linkmedia_enc = !empty($linkmedia) ? rawurlencode($linkmedia) : false;
return compact('linkname', 'linkname_enc', 'linkurl', 'linkurl_enc', 'linkmedia', 'linkmedia_enc');
}
示例9: __construct
/**
* Initializes this object to default data
*/
public function __construct()
{
$tempate_directory_uri = get_template_directory_uri();
$title = get_bloginfo('name') . wp_title(null, false);
$description = get_bloginfo('description');
$this->set_title($title)->set_meta_tag(array('name' => 'description', 'content' => $description))->set_meta_tag(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'))->set_charset(get_bloginfo('charset'))->set_link(array('rel' => 'shortcut icon', 'href' => "{$tempate_directory_uri}/images/favicon.png"));
}
示例10: breadcrumbs
function breadcrumbs()
{
$theFullUrl = $_SERVER["REQUEST_URI"];
$urlArray = explode("/", $theFullUrl);
//echo 'You Are Here: <a href="/">Home</a>';
echo "<div class='breadcrumbs_div'>";
echo "<div class='breadcrumbs'><ul>";
while (list($j, $text) = each($urlArray)) {
$dir = '';
if ($j > 1) {
$i = 1;
while ($i < $j) {
$dir .= '/' . $urlArray[$i];
$text = $urlArray[$i];
$i++;
}
if ($j < count($urlArray) - 1) {
echo ' <li><a href="' . $dir . '">' . str_replace("-", " ", $text) . '</a></li>';
}
}
}
echo "</ul></div>";
echo "<div class='current'>" . wp_title('', false) . '<img class="current_img" width="11" height="17" border="0" src="/wp-content/themes/crikey/img/left_arrow.png" alt=">">' . "</div></div>";
echo '<div class="clear"></div>';
}
示例11: perfect_title
/**
* Prints better page title
*/
function perfect_title()
{
echo '<title>';
if (function_exists('is_tag') && is_tag()) {
single_tag_title(__('Tag Archive for') . '"');
$output .= '" - ';
} elseif (is_archive()) {
wp_title('');
echo __('Archive') . ' - ';
} elseif (is_search()) {
echo __('Search for') . '"' . esc_html($s) . '" - ';
} elseif (!is_404() && is_single() || is_page()) {
wp_title('');
echo ' - ';
} elseif (is_404()) {
echo __('Not Found') . '-';
}
if (is_home()) {
bloginfo('name');
echo ' - ';
bloginfo('description');
} else {
bloginfo('name');
}
if ($paged > 1) {
echo ' - ' . __('page') . ' ' . $paged;
}
echo '</title>';
}
示例12: 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 = '·')
{
_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;
}
示例13: add_scripts
/**
* Enqueue scripts and styles
*/
function add_scripts()
{
if (empty($GLOBALS['posts']) || !is_array($GLOBALS['posts'])) {
return;
}
foreach ($GLOBALS['posts'] as $p) {
if (has_shortcode($p->post_content, 'recipe')) {
$this->scripts_and_style_included = true;
break;
}
}
if (!$this->scripts_and_style_included) {
return;
}
if (is_rtl()) {
wp_enqueue_style('jetpack-recipes-style', plugins_url('/css/rtl/recipes-rtl.css', __FILE__), array(), '20130919');
} else {
wp_enqueue_style('jetpack-recipes-style', plugins_url('/css/recipes.css', __FILE__), array(), '20130919');
}
wp_enqueue_script('jetpack-recipes-printthis', plugins_url('/js/recipes-printthis.js', __FILE__), array('jquery'), '20131230');
wp_enqueue_script('jetpack-recipes-js', plugins_url('/js/recipes.js', __FILE__), array('jquery', 'jetpack-recipes-printthis'), '20131230');
$title_var = wp_title('|', false, 'right');
$print_css_var = plugins_url('/css/recipes-print.css', __FILE__);
wp_localize_script('jetpack-recipes-js', 'jetpack_recipes_vars', array('pageTitle' => $title_var, 'loadCSS' => $print_css_var));
}
示例14: tarski_doctitle
/**
* 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
* @param string $sep
* @return string $doctitle
* @hook filter tarski_doctitle
* Filter document titles.
*/
function tarski_doctitle($sep = '·')
{
$site_name = get_bloginfo('name');
if (is_404()) {
$content = __(sprintf('Error %s', '404'), 'tarski');
} elseif (get_option('show_on_front') == 'posts' && is_home()) {
if (get_bloginfo('description')) {
$content = get_bloginfo('description');
}
} elseif (is_search()) {
$content = sprintf(__('Search results for %s', 'tarski'), attribute_escape(get_search_query()));
} elseif (is_month()) {
$content = single_month_title(' ', false);
} elseif (is_tag()) {
$content = multiple_tag_titles();
} else {
$content = trim(wp_title('', false));
}
if ($content) {
$elements = array('site_name' => $site_name, 'separator' => $sep, 'content' => $content);
} else {
$elements = 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 (check_input($elements, 'array')) {
$doctitle = implode(' ', $elements);
}
echo $doctitle;
}
示例15: set_cookie
public static function set_cookie($data = '')
{
$data = wp_parse_args($data, array('query' => json_encode($GLOBALS['wp_query']->query), 'url' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'title' => trim(wp_title(self::SEP, false, 'left'))));
foreach ($data as $key => $value) {
setcookie(self::get_name($key), $value, 0, '/');
}
}