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


PHP is_home函数代码示例

本文整理汇总了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>';
}
开发者ID:ethicalux,项目名称:kairos_eux,代码行数:44,代码来源:wp_bootstrap_breadcrumbs.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: 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());
    }
}
开发者ID:iinspiration,项目名称:theme,代码行数:31,代码来源:functions.php

示例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);
 }
开发者ID:silversite,项目名称:silverwp,代码行数:29,代码来源:Description.php

示例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;
 }
开发者ID:rvelezc,项目名称:drpelaezgo.com,代码行数:39,代码来源:class-avada-dynamic-css.php

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

示例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;
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:7,代码来源:functions.php

示例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>';
        }
    }
}
开发者ID:sykot,项目名称:wp-bs,代码行数:25,代码来源:functions.php

示例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);
    }
}
开发者ID:hscale,项目名称:webento,代码行数:7,代码来源:my-functions.php

示例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'));
 }
开发者ID:plusplusminus,项目名称:athol,代码行数:29,代码来源:theme-js.php

示例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());
 }
开发者ID:dfmedia,项目名称:searchpress,代码行数:7,代码来源:test-integration.php

示例12: education_home_layout

function education_home_layout($opt)
{
    if (is_home()) {
        $opt = 'content-sidebar-sidebar';
    }
    return $opt;
}
开发者ID:nmrugg,项目名称:studiopress-premum-wp-themes,代码行数:7,代码来源:functions.php

示例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;
 }
开发者ID:neerukoul,项目名称:rtMedia,代码行数:12,代码来源:RTMediaUploadShortcode.php

示例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 
}
开发者ID:jun200,项目名称:wordpress,代码行数:32,代码来源:functions.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);
}
开发者ID:boltogriz,项目名称:blog-cook,代码行数:29,代码来源:functions.php


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