本文整理汇总了PHP中is_404函数的典型用法代码示例。如果您正苦于以下问题:PHP is_404函数的具体用法?PHP is_404怎么用?PHP is_404使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_404函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
}
开发者ID:indee,项目名称:indee-website,代码行数:33,代码来源:globals.func.php
示例2: 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
示例3: 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>';
}
开发者ID:nishant368,项目名称:newlifeoffice-new,代码行数:32,代码来源:custom.php
示例4: qtranxf_wp_head
function qtranxf_wp_head()
{
global $q_config;
if ($q_config['header_css_on']) {
echo '<style type="text/css">' . PHP_EOL . $q_config['header_css'] . '</style>' . PHP_EOL;
}
do_action('qtranslate_head_add_css');
//not really needed?
// skip the rest if 404
if (is_404()) {
return;
}
// set links to translations of current page
foreach ($q_config['enabled_languages'] as $lang) {
if (!empty($q_config['locale_html'][$lang])) {
$hreflang = $q_config['locale_html'][$lang];
} else {
$hreflang = $lang;
}
//if($language != qtranxf_getLanguage())//standard requires them all
echo '<link hreflang="' . $hreflang . '" href="' . qtranxf_convertURL('', $lang, false, true) . '" rel="alternate" />' . PHP_EOL;
}
//https://support.google.com/webmasters/answer/189077
echo '<link hreflang="x-default" href="' . qtranxf_convertURL('', $q_config['default_language']) . '" rel="alternate" />' . PHP_EOL;
//qtranxf_add_css();// since 3.2.5 no longer needed
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:26,代码来源:qtranslate_frontend.php
示例5: get_language_from_content
/**
* returns the language based on the queried content
*
* @since 1.2
*
* @return object|bool detected language, false if none was found
*/
protected function get_language_from_content()
{
// no language set for 404
if (is_404() || is_attachment() && !$this->options['media_support']) {
return $this->get_preferred_language();
}
if ($var = get_query_var('lang')) {
$lang = explode(',', $var);
$lang = $this->model->get_language(reset($lang));
// choose the first queried language
} elseif ((is_single() || is_page() || is_attachment() && $this->options['media_support']) && (($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')))) {
$lang = $this->model->post->get_language($var);
} else {
foreach ($this->model->get_translated_taxonomies() as $taxonomy) {
if ($var = get_query_var(get_taxonomy($taxonomy)->query_var)) {
$lang = $this->model->term->get_language($var, $taxonomy);
}
}
}
/**
* Filter the language before it is set from the content
*
* @since 0.9
*
* @param bool|object $lang language object or false if none was found
*/
return apply_filters('pll_get_current_language', isset($lang) ? $lang : false);
}
开发者ID:JoryHogeveen,项目名称:polylang,代码行数:35,代码来源:choose-lang-content.php
示例6: featureText
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());
}
}
开发者ID:jrock89,项目名称:JRockWeb2,代码行数:28,代码来源:functions.php
示例7: bavota_breadcrumbs
function bavota_breadcrumbs()
{
if (!is_front_page()) {
echo '<a href="' . home_url('/') . 'blog">Blog</a><span class="divider"> <i class="icon-angle-right"></i> </span>';
}
if (is_category() || is_single()) {
$category = get_the_category();
$ID = $category[0]->cat_ID;
// echo get_category_parents($ID, TRUE, ' ', FALSE ); // was causing errors in the error_log
echo is_wp_error($cat_parents = get_category_parents($ID, TRUE, ' ', FALSE)) ? '' : $cat_parents;
}
$mytitle = get_the_title();
if (strlen($mytitle) > 22) {
$mytitle = substr($mytitle, 0, 38) . "...";
}
if (is_single() || is_page()) {
echo ' <span class="divider"> <i class="icon-angle-right"></i> </span> ';
echo $mytitle;
}
if (is_tag()) {
echo "Tag: " . single_tag_title('', FALSE);
}
if (is_404()) {
echo "404 - Page not Found";
}
if (is_search()) {
echo "Search";
}
if (is_year()) {
echo get_the_time('Y');
}
}
开发者ID:jonbrown21,项目名称:JBD-Wordpress-Theme,代码行数:32,代码来源:functions.php
示例8: dbdb_body_classes
/**
* Custom class for the WP 'body_class()' function
* updated: 4/15/10
*/
function dbdb_body_classes($classes)
{
// source http://darrinb.com/notes/2010/customizing-the-wordpress-body_class-function/
global $post;
global $wp_query;
// if there is no parent ID and it's not a single post page, category page, or 404 page, give it
// a class of "parent-page"
if ($post->post_parent < 1 && !is_single() && !is_archive() && !is_404()) {
$classes[] = 'parent-page';
}
// if the page/post has a parent, it's a child, give it a class of its parent name
if ($post->post_parent > 0) {
/* $parent_title = get_the_title($wp_query->post->post_parent);
$parent_title = preg_replace('#\s#','-', $parent_title);
$parent_title = strtolower($parent_title);
$classes[] = 'parent-pagename-'.$parent_title; */
$parent_id = wp_get_post_parent_id($wp_query->post);
// $parent_id = get_the_ID($wp_query->post->post_parent);
echo "PARENT ID : " . $parent_id;
// $parent_id = preg_replace('#\s#','-', $parent_id);
$parent_id = strtolower($parent_id);
$classes[] = 'parent-id-' . $parent_id;
}
// add a class = to the name of post or page
$classes[] = $wp_query->queried_object->post_name;
return array_unique($classes);
}
开发者ID:aldelpech,项目名称:clea-atouts-c,代码行数:31,代码来源:functions.php
示例9: cinnamon_wp_title
/**
* Filters wp_title to print a neat <title> tag based on what is being viewed.
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string The filtered title.
*/
function cinnamon_wp_title($title, $sep)
{
/**
* If this is version 4.1, directly stop the manual title modification. Let WordPress does that through add_theme_support( 'title-tag' );
*/
if (function_exists('_wp_render_title_tag')) {
return $title;
}
if (is_feed()) {
return $title;
}
global $page, $paged;
// Add the blog name
$title .= get_bloginfo('name', 'display');
// Add the blog description for the home/front page.
$site_description = get_bloginfo('description', 'display');
if ($site_description && (is_home() || is_front_page())) {
$title .= " {$sep} {$site_description}";
}
// Add a page number if necessary:
if (($paged >= 2 || $page >= 2) && !is_404()) {
$title .= " {$sep} " . sprintf(__('Page %s', 'cinnamon'), max($paged, $page));
}
return $title;
}
开发者ID:jeremygeltman,项目名称:ThinkThinly,代码行数:32,代码来源:extras.php
示例10: get_the_ID
/**
* Get the ID for the current post
*/
private function get_the_ID()
{
if (is_404()) {
return '';
}
return get_the_ID();
}
开发者ID:setola,项目名称:wordpress-theme-utils-classes,代码行数:10,代码来源:RuntimeInfos.class.php
示例11: display
function display($args = array())
{
/* Use the generic_content action if it's set. See http://core.trac.wordpress.org/ticket/20509 */
if ($this->get_setting('mode', 'default') == 'default' && has_action('generic_content') && !did_action('generic_content')) {
return do_action('generic_content');
}
/* Since it's impossible to get the $wp_query in its correct form when loading the content from admin-ajax.php, we will display this notice. */
if (headway_get('ve-live-content-query', $this->block, false) && $this->get_setting('mode', 'default') == 'default') {
echo '<div class="alert alert-yellow" style="margin: 5px;"><p><strong>Please note:</strong> What\'s being displayed here in the Content Block may not be correct. When viewing the site outside of the Visual Editor, you will see the correct content.</p></div>';
}
/* If LoopBuddy is activated, we'll strictly rely on it for the query setup and how the content is displayed. */
if (class_exists('pluginbuddy_loopbuddy')) {
global $pluginbuddy_loopbuddy;
$loopbuddy_query = $this->get_setting('loopbuddy-query', -1);
$loopbuddy_layout = $this->get_setting('loopbuddy-layout', -1);
if (isset($pluginbuddy_loopbuddy) && $loopbuddy_query !== -1) {
echo $pluginbuddy_loopbuddy->render_loop($loopbuddy_query, $loopbuddy_layout);
$this->remove_hooks();
return;
}
}
/* Display the 404 text if it's a 404 (has to be default behavior) */
if (is_404() && $this->get_setting('mode', 'default') == 'default' && !headway_get('ve-live-content-query', $this->block, false)) {
$this->remove_hooks();
return $this->display_404();
}
/* Display loop like normal if nothing else fires first */
$this->loop($args);
$this->remove_hooks();
wp_reset_query();
}
开发者ID:danaiser,项目名称:hollandLawns,代码行数:31,代码来源:content-display.php
示例12: 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
示例13: ubik_seo_meta_description
function ubik_seo_meta_description($desc = '')
{
// Generate a meta description
if (empty($desc)) {
// Single posts, pages, and attachments
if (is_singular()) {
$post = get_post();
if (empty($post)) {
$desc = '';
}
$desc = wptexturize($post->post_content);
// Get the entire contents, not the excerpt, so as to not duplicate Ubik Excerpt
}
// Check to see if we have a description for this category, tag, or taxonomy
if (is_category() || is_tag() || is_tax()) {
$desc = term_description();
}
// Now match other possibilities...
if (is_author()) {
$desc = get_the_author_meta('description');
}
// Front or home page
if (is_front_page() || is_home()) {
$desc = get_bloginfo('description');
}
// No excerpt to return
if (is_404() || is_search()) {
$desc = '';
}
$desc = ubik_seo_meta_description_sanitize($desc);
}
return apply_filters('ubik_seo_meta_description', $desc);
}
开发者ID:synapticism,项目名称:ubik-seo,代码行数:33,代码来源:ubik-seo-meta-description.php
示例14: so_body_classes
/**
* Add our own classes to the body_class function
* adapted from: http://www.mimoymima.com/2013/01/lab/better-body-class-function-wordpress/
*
* @20131220: This in an update to the earlier code, where it was needed to change the call to the body_class.
* with the snippet below however that is no longer necessary and as an additional advantage it also keeps the
* original WordPress body class which may (or may not) come in handy one day.
*
* @20140423 adjusted the code to make it more useful
*/
function so_body_classes($classes)
{
global $post;
// return some of these things
if (is_category()) {
$classes[] = 'cat-archive';
} elseif (is_search()) {
$classes[] = 'search-page';
} elseif (is_tag()) {
$classes[] = 'tag-archive';
} elseif (is_home()) {
$classes[] = 'home-page';
} elseif (is_404()) {
$classes[] = 'error-page';
}
// return page-(page name)
if (is_page()) {
$pn = $post->post_name;
$classes[] = 'page-' . $pn;
}
if (is_page() && $post->post_parent) {
$classes[] = 'child-of-' . $parentSlug;
}
// if WPML has been installed return the language code
if (in_array('sitepress-multilingual-cms/sitepress.php', apply_filters('active_plugins', get_option('active_plugins')))) {
if (defined('ICL_LANGUAGE_CODE')) {
$lang = 'lang-' . ICL_LANGUAGE_CODE;
$classes[] = $lang;
}
}
return $classes;
}
开发者ID:SpiritPixels,项目名称:Code-Snippets,代码行数:42,代码来源:better-body-class.php
示例15: getBodyClasses
/**
*
* Returns the list of classes
*
* @param $post
* @return array
* @author Tim Perry
*/
protected function getBodyClasses($post)
{
$classes = array();
if (is_single()) {
$classes[] = "single";
} else {
$classes[] = "page";
}
if (is_page()) {
$classes[] = 'page--' . $post->post_name;
}
if (is_404()) {
$classes[] = 'page--404';
} elseif (is_front_page()) {
$classes[] = 'page--front';
} elseif (is_home()) {
$classes[] = 'page--news';
} elseif (is_search()) {
$classes[] = 'page--search';
} elseif (is_single() && ($postType = strtolower(str_replace("_", "-", $post->post_type)))) {
$classes[] = "single--" . $postType;
}
if (is_user_logged_in()) {
$classes[] = 'has-admin-bar';
}
return $classes;
}
开发者ID:flexpress,项目名称:component-templating,代码行数:35,代码来源:BodyClasses.php
示例16: fortyfourwp_setTemplate
function fortyfourwp_setTemplate($page_template)
{
if (is_404()) {
$page_template = dirname(__DIR__) . '/views/page-404.php';
}
return $page_template;
}
开发者ID:phpbits,项目名称:forty-four,代码行数:7,代码来源:functions.display.php
示例17: getWpTemplate
function getWpTemplate()
{
if (defined('WP_USE_THEMES') && WP_USE_THEMES) {
$template = false;
if (is_404() && ($template = get_404_template())) {
} elseif (is_search() && ($template = get_search_template())) {
} elseif (is_tax() && ($template = get_taxonomy_template())) {
} elseif (is_front_page() && ($template = get_front_page_template())) {
} elseif (is_home() && ($template = get_home_template())) {
} elseif (is_attachment() && ($template = get_attachment_template())) {
} elseif (is_single() && ($template = get_single_template())) {
} elseif (is_page() && ($template = get_page_template())) {
} elseif (is_category() && ($template = get_category_template())) {
} elseif (is_tag() && ($template = get_tag_template())) {
} elseif (is_author() && ($template = get_author_template())) {
} elseif (is_date() && ($template = get_date_template())) {
} elseif (is_archive() && ($template = get_archive_template())) {
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
} elseif (is_paged() && ($template = get_paged_template())) {
} else {
$template = get_index_template();
}
return str_replace(ABSPATH, '', $template);
} else {
return null;
}
}
开发者ID:jtomeck,项目名称:jtwebfolio,代码行数:27,代码来源:showThemeFile.php
示例18: getPost
function getPost()
{
$data = new stdClass();
$categoryId = (int) get_query_var('cat');
if (is_tag()) {
$data->post = get_post(ThemeOption::getOption('blog_search_post_id'));
$tagQuery = get_query_var('tag');
$tagData = get_tags(array('slug' => $tagQuery));
$data->post->post_title = esc_html($tagData[0]->name);
} elseif (is_category($categoryId)) {
$category = get_category($categoryId);
$data->post = get_post(ThemeOption::getOption('blog_category_post_id'));
$data->post->post_title = ThemeHelper::esc_html($category->name);
} elseif (is_day()) {
$data->post = get_post(ThemeOption::getOption('blog_archive_post_id'));
$data->post->post_title = get_the_date();
} elseif (is_archive()) {
$data->post = get_post(ThemeOption::getOption('blog_archive_post_id'));
$data->post->post_title = single_month_title(' ', false);
} elseif (is_search()) {
$data->post = get_post(ThemeOption::getOption('blog_search_post_id'));
$data->post->post_title = sprintf(__('Search result for phrase <i>%s</i>', THEME_DOMAIN), esc_html(get_query_var('s')));
} elseif (is_404()) {
$data->post = get_post(ThemeOption::getOption('page_404_page_id'));
$data->post->post_title = $data->post->post_title;
} else {
return false;
}
return $data;
}
开发者ID:annguyenit,项目名称:HawaiiEducation,代码行数:30,代码来源:Theme.Post.class.php
示例19: 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
示例20: display
/**
* Display breadcrumbs
*/
public function display()
{
if (Habakiri::get('is_displaying_bread_crumb') === 'false') {
return;
}
global $wp_query;
// Set to home
$home_label = $this->get_home_label();
$this->set($home_label, home_url('/'));
// Set to blog
$post_type = $this->get_post_type();
if (is_category() || is_tag() || is_date() || is_author() || is_single() && $post_type === 'post') {
$show_on_front = get_option('show_on_front');
$page_for_posts = get_option('page_for_posts');
if ($show_on_front === 'page' && $page_for_posts) {
$this->set(get_the_title($page_for_posts), get_permalink($page_for_posts));
}
}
// Set current and ancestors
if (is_404()) {
$this->set_for_404();
} elseif (is_search()) {
$this->set_for_search();
} elseif (is_tax()) {
$this->set_for_tax();
} elseif (is_attachment()) {
$this->set_for_attachment();
} elseif (is_page() && !is_front_page()) {
$this->set_for_page();
} elseif (is_post_type_archive()) {
$this->set_for_post_type_archive();
} elseif (is_single()) {
$this->set_for_single();
} elseif (is_category()) {
$this->set_for_category();
} elseif (is_tag()) {
$this->set_for_tag();
} elseif (is_author()) {
$this->set_for_author();
} elseif (is_day()) {
$this->set_for_day();
} elseif (is_month()) {
$this->set_for_month();
} elseif (is_year()) {
$this->set_for_year();
} elseif (is_home() && !is_front_page()) {
$this->set_for_blog();
}
$bread_crumb = array();
$last_item = array_pop($this->bread_crumb);
foreach ($this->bread_crumb as $_bread_crumb) {
if (!empty($_bread_crumb['link'])) {
$bread_crumb[] = sprintf('<a href="%s">%s</a>', esc_url($_bread_crumb['link']), esc_html($_bread_crumb['title']));
} else {
$bread_crumb[] = esc_html($_bread_crumb['title']);
}
}
$bread_crumb[] = sprintf('<strong>%s</strong>', $last_item['title']);
printf('<div class="breadcrumbs">%s</div>', implode(' > ', apply_filters('habakiri_bread_crumb', $bread_crumb)));
}
开发者ID:ConductiveIO,项目名称:mbrady,代码行数:63,代码来源:class.breadcrumbs.php
注:本文中的is_404函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论