本文整理汇总了PHP中is_home函数的典型用法代码示例。如果您正苦于以下问题:PHP is_home函数的具体用法?PHP is_home怎么用?PHP is_home使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_home函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap_breadcrumbs
/**
* Add breadcrumbs functionality to your WordPress theme
*
* Once you have included the function in your functions.php file
* you can then place the following anywhere in your theme templates
* if(function_exists('bootstrap_breadcrumbs')) bootstrap_breadcrumbs();
*
* credit to: c.bavota - http://bavotasan.com (thanks for the code start)
*/
function bootstrap_breadcrumbs()
{
echo '<ol class="breadcrumb">';
echo '<li><a href="' . home_url('/') . '">Home</a></li>';
// are we at "blog home"?
if (is_home()) {
echo '<li><a href="#">Blogs</a></li>';
}
// where else do we want breadcrumbs
if (!is_page_template('pt-home.php') && !is_home()) {
// check if we're in a commerce plugin
if (function_exists('is_woocommerce') && is_woocommerce()) {
echo '<li><a href="/publications/order/">Shop</a></li>';
$product_cats = wp_get_post_terms(get_the_ID(), 'product_cat');
echo '<li><a href="/publications/order/' . str_replace(" ", "-", $product_cats[0]->name) . '">' . $product_cats[0]->name . '</a></li>';
}
// breadcrumb wordpress structures
if (is_category() || is_single() || is_single('aof')) {
if (get_the_category()) {
$category = get_the_category();
echo '<li><a href="/blog/category/' . str_replace(" ", "-", $category[0]->cat_name) . '">' . $category[0]->cat_name . '</a></li>';
}
if (is_single()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
} elseif (is_page()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
}
echo '</ol>';
}
示例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;
}
示例3: et_home_posts_query
/**
* Filters the main query on homepage
*/
function et_home_posts_query($query = false)
{
/* Don't proceed if it's not homepage or the main query */
if (!is_home() || !is_a($query, 'WP_Query') || !$query->is_main_query()) {
return;
}
if ('false' == et_get_option('feather_blog_style', 'false')) {
if ('on' == et_get_option('feather_display_recentwork_section', 'on')) {
$query->set('posts_per_page', (int) et_get_option('feather_posts_media', '8'));
$exclude_media_categories = et_get_option('feather_exlcats_media', false);
if ($exclude_media_categories) {
$query->set('category__not_in', array_map('intval', et_generate_wpml_ids($exclude_media_categories, 'category')));
}
}
return;
}
/* Set the amount of posts per page on homepage */
$query->set('posts_per_page', (int) et_get_option('feather_homepage_posts', '6'));
/* Exclude categories set in ePanel */
$exclude_categories = et_get_option('feather_exlcats_recent', false);
if ($exclude_categories) {
$query->set('category__not_in', array_map('intval', et_generate_wpml_ids($exclude_categories, 'category')));
}
/* Exclude slider posts, if the slider is activated, pages are not featured and posts duplication is disabled in ePanel */
if ('on' == et_get_option('feather_featured', 'on') && 'false' == et_get_option('feather_use_pages', 'false') && 'false' == et_get_option('feather_duplicate', 'on')) {
$query->set('post__not_in', et_get_featured_posts_ids());
}
}
示例4: start_el
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
{
$indent = $depth ? str_repeat("\t", $depth) : '';
$class_names = $value = '';
$classes = empty($item->classes) ? array() : (array) $item->classes;
$class_names = \join(' ', \apply_filters('nav_menu_css_class', \array_filter($classes), $item));
$class_names = ' class="' . \esc_attr($class_names) . '"';
$output .= $indent . '<li id="menu-item-' . $item->ID . '"' . $value . $class_names . '>';
$attributes = !empty($item->attr_title) ? ' title="' . \esc_attr($item->attr_title) . '"' : '';
$attributes .= !empty($item->target) ? ' target="' . \esc_attr($item->target) . '"' : '';
$attributes .= !empty($item->xfn) ? ' rel="' . \esc_attr($item->xfn) . '"' : '';
if ($item->object == 'page') {
$varpost = \get_post($item->object_id);
if (\is_home()) {
$attributes .= ' href="#' . $varpost->post_name . '"';
} else {
$attributes .= ' href="' . \home_url() . '/#' . $varpost->post_name . '"';
}
} else {
$attributes .= !empty($item->url) ? ' href="' . \esc_attr($item->url) . '"' : '';
}
$item_output = $args->before;
$item_output .= '<a' . $attributes . '>';
$item_output .= $args->link_before . \apply_filters('the_title', $item->title, $item->ID);
$item_output .= $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= \apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
示例5: page_id
/**
* get the current page ID.
*
* @return int the current page ID.
*/
public function page_id()
{
global $post;
if (isset($post)) {
/**
* Get the current post ID
*/
$id = $post->ID;
/**
* If we're on the posts page, get the ID of the page
* using the 'page_for_posts' option.
*/
if (is_home()) {
$id = get_option('page_for_posts');
} else {
/**
* I we're on the WooCommerce shop page, get the ID of the page
* using the 'woocommerce_shop_page_id' option
*/
if (function_exists('is_shop') && is_shop()) {
$id = get_option('woocommerce_shop_page_id');
} else {
/**
* If this is a singular page/post then set ID to the page ID.
* If not, then set it to false.
*/
$id = is_singular() ? $post->ID : false;
}
}
} else {
$id = false;
}
return $id;
}
示例6: 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);
}
示例7: my_get_posts
function my_get_posts($query)
{
if (is_home() && $query->is_main_query()) {
$query->set('post_type', array('post', 'screenshot', 'trailer'));
}
return $query;
}
示例8: MyBreadcrumb
function MyBreadcrumb()
{
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '/">';
echo 'Home';
echo '</a><span class="divider">/</span></li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(', ', '&title_li=');
echo '<span class="divider">/</span></li>';
echo '</li>';
if (is_single()) {
echo '<li class="active">';
// the_title();
echo '</li>';
}
} elseif (is_page()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
}
}
示例9: gc_enterprise_bp_head
function gc_enterprise_bp_head()
{
remove_action('genesis_after_footer', 'bp_core_admin_bar', 88);
if (gconnect_have_adminbar() && (!is_home() || gconnect_get_option('adminbar'))) {
add_action('genesis_after_footer', 'gc_enterprise_adminbar', 88);
}
}
示例10: woothemes_add_javascript
function woothemes_add_javascript()
{
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script('third-party', get_template_directory_uri() . '/includes/js/third-party' . $suffix . '.js', array('jquery'));
wp_register_script('flexslider', get_template_directory_uri() . '/includes/js/jquery.flexslider' . $suffix . '.js', array('jquery'));
wp_register_script('prettyPhoto', get_template_directory_uri() . '/includes/js/jquery.prettyPhoto' . $suffix . '.js', array('jquery'));
wp_register_script('portfolio', get_template_directory_uri() . '/includes/js/portfolio' . $suffix . '.js', array('jquery', 'prettyPhoto'));
wp_enqueue_script('modernizr', get_template_directory_uri() . '/includes/js/modernizr' . $suffix . '.js', array('jquery'), '2.6.2');
// Conditionally load the Slider and Portfolio JavaScript, where needed.
$load_slider_js = false;
$load_portfolio_js = false;
if (get_option('woo_slider_magazine') == 'true' && is_page_template('template-magazine.php') || get_option('woo_slider_biz') == 'true' && is_page_template('template-biz.php') || is_page_template('template-widgets.php') || is_active_sidebar('homepage') && (is_home() || is_front_page())) {
$load_slider_js = true;
}
if (is_page_template('template-portfolio.php') || is_singular() && get_post_type() == 'portfolio' || is_post_type_archive('portfolio') || is_tax('portfolio-gallery')) {
$load_portfolio_js = true;
}
// Allow child themes/plugins to load the slider and portfolio JavaScript when they need it.
$load_slider_js = apply_filters('woo_load_slider_js', $load_slider_js);
$load_portfolio_js = apply_filters('woo_load_portfolio_js', $load_portfolio_js);
if ($load_slider_js) {
wp_enqueue_script('flexslider');
}
if ($load_portfolio_js) {
wp_enqueue_script('portfolio');
}
do_action('woothemes_add_javascript');
wp_enqueue_script('general', get_template_directory_uri() . '/includes/js/general' . $suffix . '.js', array('jquery', 'third-party'));
}
示例11: test_sp_query_arg
function test_sp_query_arg()
{
$this->go_to('/?sp[force]=1');
$this->assertEquals(get_query_var('sp'), array('force' => '1'));
$this->assertTrue(is_search());
$this->assertFalse(is_home());
}
示例12: education_home_layout
function education_home_layout($opt)
{
if (is_home()) {
$opt = 'content-sidebar-sidebar';
}
return $opt;
}
示例13: display_allowed
/**
* Helper function to check whether the shortcode should be rendered or not
*
* @return type
*/
static function display_allowed()
{
global $rtmedia_query;
$flag = !(is_home() || is_post_type_archive() || is_author()) && is_user_logged_in() && (is_rtmedia_upload_music_enabled() || is_rtmedia_upload_photo_enabled() || is_rtmedia_upload_video_enabled()) && (isset($rtmedia_query->is_upload_shortcode) && $rtmedia_query->is_upload_shortcode == true || is_rtmedia_bp_profile() && is_rtmedia_profile_media_enable() || is_rtmedia_bp_group() && is_rtmedia_group_media_enable());
$flag = apply_filters('before_rtmedia_uploader_display', $flag);
return $flag;
}
示例14: family_banner
function family_banner()
{
?>
<div class="banner">
<div class="wrap">
<?php
if (is_front_page()) {
family_get_header_image();
} elseif (!is_front_page() && get_theme_mod('family_header_home')) {
echo '';
} else {
// get title
$id = get_option('page_for_posts');
if ('posts' == get_option('show_on_front') && (is_day() || is_month() || is_year() || is_tag() || is_category() || is_singular('post') || is_home())) {
family_get_header_image();
} elseif (is_home() || is_singular('post')) {
if (has_post_thumbnail($id)) {
echo get_the_post_thumbnail($id, 'full');
} else {
family_get_header_image();
}
} elseif (has_post_thumbnail() && is_singular('page')) {
the_post_thumbnail();
} else {
family_get_header_image();
}
}
?>
</div><!-- .wrap -->
</div><!-- .banner -->
<?php
}
示例15: wpthemes_post_class
function wpthemes_post_class($class = '', $post_id = null)
{
$post = get_post($post_id);
$classes = array();
$classes[] = $post->post_type;
if (is_sticky($post->ID) && is_home()) {
$classes[] = 'sticky';
}
$classes[] = 'hentry';
foreach ((array) get_the_category($post->ID) as $cat) {
if (empty($cat->slug)) {
continue;
}
$classes[] = 'category-' . $cat->slug;
}
foreach ((array) get_the_tags($post->ID) as $tag) {
if (empty($tag->slug)) {
continue;
}
$classes[] = 'tag-' . $tag->slug;
}
if (!empty($class)) {
if (!is_array($class)) {
$class = preg_split('#\\s+#', $class);
}
$classes = array_merge($classes, $class);
}
return apply_filters('post_class', $classes, $class, $post_id);
}