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


PHP is_category函数代码示例

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


在下文中一共展示了is_category函数的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: 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

示例3: get_index_headline

function get_index_headline()
{
    if (is_home()) {
        $index_headline = 'Blog Index';
    } else {
        if (is_category()) {
            $category = single_term_title("", false);
            $index_headline = 'Archives for the "' . $category . '" Category';
        } elseif (is_tag()) {
            $tag = single_term_title("", false);
            $index_headline = 'Archives for the "' . $tag . '" Category';
        } elseif (is_day()) {
            $index_headline = 'Archive for ' . get_the_time('F jS, Y');
        } elseif (is_month()) {
            $index_headline = 'Archive for ' . get_the_time('F Y');
        } elseif (is_year()) {
            $index_headline = 'Archive for ' . get_the_time('Y');
        } elseif (is_author()) {
            $index_headline = 'Author Archive';
        } else {
            $index_headline = 'Blog Archives';
        }
    }
    return $index_headline;
}
开发者ID:jordanmaslyn,项目名称:vvv-starter,代码行数:25,代码来源:blog.php

示例4: 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

示例5: 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

示例6: my_get_posts

function my_get_posts($query)
{
    if (is_author() && $query->is_main_query() || is_category() && $query->is_main_query()) {
        $query->set('post_type', array('post', 'resources', 'news'));
    }
    return $query;
}
开发者ID:alastair38,项目名称:begood2016,代码行数:7,代码来源:functions.php

示例7: widget

 function widget($args, $instance)
 {
     global $wp_query;
     $facets = elasticsearch\Faceting::all();
     $url = null;
     if (is_category() || is_tax()) {
         $url = get_term_link($wp_query->queried_object);
     } elseif (is_tag()) {
         $url = get_tag_link($wp_query->queried_object->term_id);
     } elseif (is_archive()) {
         $url = get_post_type_archive_link($wp_query->queried_object->query_var);
     } elseif (is_search()) {
         $url = home_url('/');
     }
     foreach ($facets as $type => $facet) {
         if (count($facet['selected']) > 0) {
             $name = $type;
             if (taxonomy_exists($type)) {
                 $name = get_taxonomy($type)->label;
             }
             echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">';
             echo '<h3 class="widget-title">' . $name . '</h3>';
             echo '<ul>';
             foreach ($facet['selected'] as $option) {
                 $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']);
                 echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">';
                 echo '<a href="' . $url . '">' . $option['name'] . '</a>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</aside>';
         }
     }
 }
开发者ID:pivotlearning,项目名称:wpsite,代码行数:34,代码来源:widget.php

示例8: getWordPressPageType

 /**
  * Gets the page type from WordPress.
  *
  * @return string A string representation of the current page type,
  *     corresponding to the values used by publisherplugin.google.com.
  */
 public static function getWordPressPageType()
 {
     // is_front_page() returns true if (1) a static front page is set and this
     // is that page, or (2) the front page is the blog home page and this
     // is the blog home page.
     if (is_front_page()) {
         return 'front';
     }
     if (is_home()) {
         return 'home';
     }
     if (is_single()) {
         return 'singlePost';
     }
     if (is_page()) {
         return 'page';
     }
     if (is_category()) {
         return 'category';
     }
     if (is_archive()) {
         return 'archive';
     }
     if (is_search()) {
         return 'search';
     }
     if (is_404()) {
         return 'errorPage';
     }
     return '';
 }
开发者ID:thabofletcher,项目名称:tc-site,代码行数:37,代码来源:Utils.php

示例9: tags

 public function tags()
 {
     if (!did_action('pre_get_posts')) {
         return array();
     }
     $queried_object = get_queried_object();
     $tags = array();
     $default_tags = array('og:type' => 'website', 'og:locale' => get_locale(), 'og:site_name' => get_bloginfo('name'), 'og:image' => $this->get_image_url());
     if (is_front_page()) {
         $tags = array('og:url' => home_url('/'), 'og:title' => get_bloginfo('name'), 'og:description' => get_bloginfo('description'));
     } else {
         if (is_singular()) {
             $tags = array('og:type' => 'article', 'og:url' => get_permalink($queried_object), 'og:title' => get_the_title($queried_object), 'og:description' => $this->generate_preview($queried_object->post_content), 'article:published_time' => date('c', strtotime($queried_object->post_date_gmt)), 'article:modified_time' => date('c', strtotime($queried_object->post_modified_gmt)), 'article:author' => get_author_posts_url($queried_object->post_author));
         } else {
             if (is_tax() || is_category() || is_tag()) {
                 $tags = array('og:url' => get_term_link($queried_object), 'og:title' => $queried_object->name, 'og:description' => $this->generate_preview($queried_object->description));
             } else {
                 if (is_author()) {
                     $tags = array('og:type' => 'profile', 'og:url' => get_author_posts_url($queried_object->ID), 'og:title' => $queried_object->display_name, 'og:description' => $this->generate_preview($queried_object->user_description), 'profile:first_name' => get_the_author_meta('first_name', $queried_object->ID), 'profile:last_name' => get_the_author_meta('last_name', $queried_object->ID));
                 }
             }
         }
     }
     $tags = array_merge($default_tags, $tags);
     return apply_filters('appthemes_open_graph_meta_tags', $tags);
 }
开发者ID:kalushta,项目名称:darom,代码行数:26,代码来源:open-graph.php

示例10: mypace_custom_navi_menu

function mypace_custom_navi_menu($classes, $item)
{
    global $wp_query;
    $singular_slug = 'service';
    $page_for_custom_type_title = 'サービス';
    $page_for_posts = get_option('page_for_posts');
    $post_type_query = $wp_query->query_vars['post_type'];
    $del_flag = true;
    $add_flag = false;
    if (is_singular('post') || is_category() || is_tag()) {
        $del_flag = false;
    } elseif (is_author() || is_date() || is_author()) {
        if (in_array($post_type_query, array('', 'post'))) {
            $del_flag = false;
        } elseif ($post_type_query == $custom_post_type) {
            $add_flag = true;
        }
    } elseif (is_tax()) {
        $taxonomy = get_taxonomy($wp_query->query_vars['taxonomy']);
        if (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == 'post') {
            $del_flag = false;
        } elseif (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == $singular_slug) {
            $add_flag = true;
        }
    } elseif (is_singular($singular_slug)) {
        $add_flag = true;
    }
    if ($del_flag && is_numeric($page_for_posts) && $item->object_id == $page_for_posts && $item->object == 'page' && ($key = array_search('current_page_parent', $classes))) {
        unset($classes[$key]);
    } elseif ($add_flag && $item->title == $page_for_custom_type_title && $item->object == 'page') {
        $classes[] = 'current_page_parent';
    }
    return $classes;
}
开发者ID:k111,项目名称:wp_theme_skeleton,代码行数:34,代码来源:functions.php

示例11: get_breadcrumbs

function get_breadcrumbs($post)
{
    echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=" . get_bloginfo('url') . " itemprop=\"url\"><span itemprop=\"title\">Home</span></a><span class=arrow>&nbsp;&nbsp;>&nbsp;&nbsp;</span></li>";
    if (is_home()) {
        $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_post_title($page->ID) . '</span></a><span class=arrow>&nbsp;&nbsp;>&nbsp;&nbsp;</span></li>';
    } elseif (is_single() || is_page()) {
        $parent_id = $post->post_parent;
        $breadcrumbs = array();
        while ($parent_id) {
            $page = get_page($parent_id);
            $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . get_the_title($page->ID) . '</span></a><span class=arrow>&nbsp;&nbsp;>&nbsp;&nbsp;</span></li>';
            $parent_id = $page->post_parent;
        }
        $breadcrumbs = array_reverse($breadcrumbs);
        foreach ($breadcrumbs as $crumb) {
            echo $crumb;
        }
        echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><span itemprop=\"title\">" . $post->post_title . "</span></li>";
    } elseif (is_category()) {
        echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_cat_title($page->ID) . '</span></a></li>';
    } elseif (is_archive()) {
        echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">Archives</span></li>';
    } elseif (is_404()) {
        echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">404 Page Not Found</span></li>';
    }
}
开发者ID:breakthroughdesign,项目名称:qaulitrol,代码行数:26,代码来源:functions.php

示例12: kb_scripts

function kb_scripts()
{
    wp_enqueue_style('Google-Fonts', 'https://fonts.googleapis.com/css?family=Roboto:300,400|Open+Sans:400,600,700');
    wp_enqueue_style('Normalizer', get_template_directory_uri() . '/normalize.css');
    wp_enqueue_style('Chosen', get_template_directory_uri() . '/chosen/chosen.css');
    wp_enqueue_style('Dropzone', get_template_directory_uri() . '/css/dropzone.css');
    wp_enqueue_style('Main', get_stylesheet_uri(), array(), '1.01', false);
    wp_enqueue_script('bx-js', get_template_directory_uri() . '/js/jquery.bxslider.min.js', array('jquery'), '1.0.1', true);
    wp_enqueue_script('easing-js', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array('jquery'), '1.0.1', true);
    wp_enqueue_script('chosen-js', get_template_directory_uri() . '/js/chosen.jquery.min.js', array('jquery'), '1.0.1', true);
    wp_enqueue_script('custom-js', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0.1', true);
    if (is_page_template(array('page-create-basic-listing.php', 'page-edit-basic-listing.php', 'page-create-paid-listing.php', 'page-edit-paid-listing.php', 'page-create-basic-listing-fr.php', 'page-edit-basic-listing-fr.php', 'page-create-paid-listing-fr.php', 'page-edit-paid-listing-fr.php'))) {
        wp_enqueue_script('dropzone', get_template_directory_uri() . '/js/dropzone.js', array('jquery'), '1.0.1', 'true');
    }
    //		if(is_page_template(array('page-create-paid-listing.php', 'page-edit-paid-listing.php'))) {
    //			wp_enqueue_script('stripejs', 'https://js.stripe.com/v2/', array(''), '1.0.1', 'false');
    //		}
    if (is_page_template('page-paid-listing.php')) {
        wp_register_script('googlemap', 'https://maps.google.com/maps/api/js?sensor=false', 'jquery');
        wp_enqueue_script('googlemap');
    }
    if (!is_admin()) {
        wp_localize_script('custom-js', 'my_ajax', array('ajaxurl' => admin_url('admin-ajax.php')));
    }
    if (is_home() || is_category() || is_archive()) {
        wp_enqueue_script('blog-js', get_template_directory_uri() . '/js/ajax-blog.js', array('jquery'), '1.0.1', true);
        global $wp_query;
        // What page are we on? And what is the pages limit?
        $max = $wp_query->max_num_pages;
        $paged = get_query_var('paged') > 1 ? get_query_var('paged') : 1;
        // Add some parameters for the JS.
        wp_localize_script('blog-js', 'pbd_alp', array('startPage' => $paged, 'maxPages' => $max, 'nextLink' => next_posts($max, false)));
    }
}
开发者ID:altim,项目名称:kallababy,代码行数:34,代码来源:functions.php

示例13: wcr_default_category_title

function wcr_default_category_title($headline, $term)
{
    if ((is_category() || is_tag()) && empty($headline)) {
        $headline = $term->name;
    }
    return $headline;
}
开发者ID:andrygorokhovets,项目名称:western,代码行数:7,代码来源:functions.php

示例14: semifolio_filter_wp_title

 function semifolio_filter_wp_title($old_title, $sep, $sep_location)
 {
     // add padding to the sep
     $ssep = ' ' . $sep . ' ';
     // find the type of index page this is
     if (is_category()) {
         $insert = $ssep . __('Category', 'slaves');
     } elseif (is_tag()) {
         $insert = $ssep . __('Tag', 'slaves');
     } elseif (is_author()) {
         $insert = $ssep . __('Author', 'slaves');
     } elseif (is_year() || is_month() || is_day()) {
         $insert = $ssep . __('Archives', 'slaves');
     } elseif (is_home()) {
         $insert = $ssep . bloginfo('description');
     } else {
         $insert = NULL;
     }
     // get the page number we're on (index)
     if (get_query_var('paged')) {
         $num = $ssep . __('Page ', 'slaves') . get_query_var('paged');
     } elseif (get_query_var('page')) {
         $num = $ssep . __('Page ', 'slaves') . get_query_var('page');
     } else {
         $num = NULL;
     }
     // concoct and return new title
     return bloginfo('name') . $insert . $old_title . $num;
 }
开发者ID:jokoprastiyo,项目名称:slaves-0.3,代码行数:29,代码来源:extras.php

示例15: 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(' &gt; ', apply_filters('habakiri_bread_crumb', $bread_crumb)));
 }
开发者ID:ConductiveIO,项目名称:mbrady,代码行数:63,代码来源:class.breadcrumbs.php


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