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


PHP get_cat_ID函数代码示例

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


在下文中一共展示了get_cat_ID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: category_count_do

 /**
  * TODO: docs
  * @param type $cat_name
  * @return type
  */
 public function category_count_do($cat_name)
 {
     $cat_id = get_cat_ID($cat_name);
     $category = get_category($cat_id);
     $count = $category->category_count;
     return "{$cat_name} ({$count})";
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:12,代码来源:postediting.php

示例2: _getPostTop

 private function _getPostTop($category)
 {
     if (empty($category)) {
         $this->_trough404('_getPostTop: No category set');
     }
     require $this->wp;
     $cid = get_cat_ID($category);
     if ($cid) {
         $wp_posts = get_posts(array('category' => get_cat_ID($category)));
         foreach ($wp_posts as $wp_post) {
             $id = $wp_post->ID;
             $tags = wp_get_post_tags($wp_post->ID);
             foreach ($tags as $tag) {
                 if ($tag->name == 'top') {
                     return $id;
                 }
             }
         }
         if (!empty($id)) {
             return $id;
         }
         // Backup, random one
     }
     $this->_trough404('_getPostTop: No category found');
 }
开发者ID:xuedi,项目名称:pedetes,代码行数:25,代码来源:core_wordpress_model.php

示例3: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     // Only show the widget if it is on a specific Page, not when just showing a single post.
     if (!$this->is_post_on_its_own_page) {
         return;
     }
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         $categories = !empty($instance['categories']) ? $instance['categories'] : array();
         $category_slug_first = '';
         $category_ids = array();
         foreach ($categories as $category) {
             if ($category_slug_first == '') {
                 $category_slug_first = strtolower(str_replace(' ', '-', $category));
             }
             $category_ids[] = get_cat_ID($category);
         }
         $ace_user = new AceCourseUser();
         echo "<div class='{$category_slug_first} " . $ace_user->get_css_classes() . "'>";
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
         $query_args = array('post_type' => 'post', 'post_status' => 'publish', 'category__in' => $category_ids);
         $exercise_posts = new \WP_Query($query_args);
         global $post;
         foreach ($exercise_posts->posts as $exercise_post) {
             $post = $exercise_post;
             setup_postdata($post);
             include 'ace-course-progress.template.php';
             wp_reset_postdata();
         }
         echo "</div>";
     }
     echo $args['after_widget'];
 }
开发者ID:RobBosman,项目名称:vanace.AceCourse,代码行数:41,代码来源:AceCourseProgressWidget.class.php

示例4: getPhotos

function getPhotos($category, $posts)
{
    $is_highlights = !is_array($posts);
    $data = !$is_highlights ? $posts : [];
    $url = 'http://' . $_SERVER['SERVER_NAME'] . '/' . 'cms/wp-json/posts?filter[posts_per_page]=-1&filter[order]=desc&filter[orderby]=post_date' . ($is_highlights ? '&filter[category_name]=destaque' : null);
    $response = \Httpful\Request::get($url)->send();
    $catId = get_cat_ID($category);
    foreach ($response->body as $key => $post) {
        $image_src = getImage($post->content);
        $attachment_id = pn_get_attachment_id_from_url($image_src);
        $image_large_src = wp_get_attachment_image_src($attachment_id, 'large');
        if (!$is_highlights && !isHighgligthCategory($catId, $post->terms->category)) {
            if ($image_src) {
                array_push($data, array('id' => $post->ID, 'title' => $post->title, 'image_src' => getImage($post->content), 'image_large_src' => $image_large_src[0]));
            }
        } else {
            if ($is_highlights && isHighgligthCategory($catId, $post->terms->category)) {
                if ($image_src) {
                    array_push($data, array('id' => $post->ID, 'title' => $post->title, 'image_src' => getImage($post->content), 'image_large_src' => $image_large_src[0]));
                }
            }
        }
    }
    return $data;
}
开发者ID:heldrida,项目名称:freedomnow,代码行数:25,代码来源:helperFns.php

示例5: render

 function render($atts, $content = null)
 {
     parent::render($atts);
     $buffy = '';
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit + 1, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     // exclude categories from the demo
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '44,45,46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 110, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title();
     if (!empty($categories)) {
         $buffy .= '<ul class="td-pb-padding-side">';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
开发者ID:vikasjain1595,项目名称:wordpresstheme,代码行数:25,代码来源:td_popular_categories.php

示例6: render

 function render($atts, $content = null)
 {
     parent::render($atts);
     $buffy = '';
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     // exclude categories from the demo
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '90, 91, 92, 93 , 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 82, 83, 84, 85, 86, 87, 88, 89, 98, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     // has a limit of 6 by default
     $buffy .= '<div class="' . $this->get_block_classes(array('widget', 'widget_categories')) . '">';
     $buffy .= $this->get_block_title();
     if (!empty($categories)) {
         $buffy .= '<ul class="td-pb-padding-side">';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
开发者ID:luxifel,项目名称:Bionerd,代码行数:26,代码来源:td_block_popular_categories.php

示例7: woo_tumblog_category_link

function woo_tumblog_category_link($post_id = 0, $type = 'articles')
{
    $category_link = '';
    if (get_option('woo_tumblog_content_method') == 'post_format') {
        $post_format = get_post_format();
        if ($post_format == '') {
            $category = get_the_category();
            $category_name = $category[0]->cat_name;
            // Get the ID of a given category
            $category_id = get_cat_ID($category_name);
            // Get the URL of this category
            $category_link = get_category_link($category_id);
        } else {
            $category_link = get_post_format_link($post_format);
        }
    } else {
        $tumblog_list = get_the_term_list($post_id, 'tumblog', '', '|', '');
        $tumblog_array = explode('|', $tumblog_list);
        ?>
		<?php 
        $tumblog_items = array('articles' => get_option('woo_articles_term_id'), 'images' => get_option('woo_images_term_id'), 'audio' => get_option('woo_audio_term_id'), 'video' => get_option('woo_video_term_id'), 'quotes' => get_option('woo_quotes_term_id'), 'links' => get_option('woo_links_term_id'));
        ?>
		<?php 
        // Get the ID of Tumblog Taxonomy
        $category_id = $tumblog_items[$type];
        $term =& get_term($category_id, 'tumblog');
        // Get the URL of Articles Tumblog Taxonomy
        $category_link = get_term_link($term, 'tumblog');
    }
    return $category_link;
}
开发者ID:niko-lgdcom,项目名称:archives,代码行数:31,代码来源:theme-tumblog.php

示例8: __construct

 public function __construct($post)
 {
     // Set Category ID Values, but First Time Only
     if (Export_ID_XML_Generator::$OPINION_CATEGORY_ID == -1) {
         Export_ID_XML_Generator::$OPINION_CATEGORY_ID = get_cat_ID("Opinion");
         Export_ID_XML_Generator::$COLUMNS_CATEGORY_ID = get_cat_ID("Columns");
     }
     $this->post = $post;
     $this->context = array();
     $this->template = $this->get_template_context();
     $this->meta = get_post_meta($post->ID, Export_ID_XML_Admin_PostMeta::$META_KEY_NAME, true);
     $this->context['url'] = $this->get_permalink();
     $this->context['headline'] = $this->get_title();
     $this->context['author'] = $this->get_author();
     $this->context['rank'] = $this->get_rank();
     $this->context['body'] = $this->get_body();
     $this->context['jumpword'] = $this->get_jumpword();
     $this->context['conthead'] = $this->get_conthead();
     $this->context['hammer'] = $this->get_hammer();
     $this->context['kicker'] = $this->get_kicker();
     $this->context['bio'] = $this->get_bio();
     $this->context['photos'] = $this->get_photos();
     // Optional for Off-the-Hill Context
     $this->context['oth'] = $this->get_oth();
 }
开发者ID:TuftsDaily,项目名称:export-id-xml,代码行数:25,代码来源:class-export-id-xml-generator.php

示例9: render

 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '251, 252, 253, 254, 255, 256, 257, 258, 305, 306, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy = '';
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title_raw($atts, 'Popular category');
     if (!empty($categories)) {
         $buffy .= '<ul>';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
开发者ID:Vatia13,项目名称:tofido,代码行数:25,代码来源:td_popular_categories.php

示例10: widget

 /**
  * Public View
  */
 function widget($args, $instance)
 {
     extract($args);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $topics = $instance['topics'];
     /* REQUIRED */
     echo $before_widget;
     /* 'before' and 'after' are REQUIRED */
     if ($title) {
         echo $before_title . $title . $after_title . '&nbsp;';
     }
     /* Display array separated by delimiter
      * TODO: make delimiter a configurable option?
      * */
     if ($topics && isset($topics)) {
         foreach ($topics as &$topic) {
             $category_id = get_cat_ID($topic);
             if (0 < $category_id) {
                 // modified the category link for the niche sites "site category" functionality
                 // @TODO: this should change in the future as we fix the niche site theme
                 $category = get_category($category_id);
                 $category_link = get_bloginfo('url') . '/category/' . $category->slug;
                 $topic = '<a href="' . $category_link . '" title="' . $topic . '">' . $topic . '</a>';
             } else {
                 //	topic is not a link
             }
         }
         echo implode(' | ', $topics);
     }
     /* REQUIRED */
     echo $after_widget;
 }
开发者ID:BryanH,项目名称:Hot-Topics-Widget,代码行数:36,代码来源:hot-topics-widget.php

示例11: oceanic_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     */
    function oceanic_post_nav()
    {
        // Don't print empty markup if there's nowhere to navigate.
        $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
        $next = get_adjacent_post(false, '', false);
        if (!$next && !$previous) {
            return;
        }
        ?>
	<nav class="navigation post-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
        _e('Post navigation', 'oceanic');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        $slider_cats = get_theme_mod('oceanic-slider-cats', false);
        $slider_cat_ids = array();
        if ($slider_cats) {
            $slider_cats = explode(',', esc_html($slider_cats));
            for ($i = 0; $i < count($slider_cats); ++$i) {
                $cat_id = get_cat_ID($slider_cats[$i]);
                if ($cat_id > 0) {
                    $slider_cat_ids[$i] = $cat_id;
                }
            }
        }
        previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">&larr;</span>&nbsp;%title', 'Previous post link', 'oceanic'), false, $slider_cat_ids);
        next_post_link('<div class="nav-next">%link</div>', _x('%title&nbsp;<span class="meta-nav">&rarr;</span>', 'Next post link', 'oceanic'), false, $slider_cat_ids);
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:neetudave,项目名称:heartfulness-uk,代码行数:37,代码来源:template-tags.php

示例12: posthasteCatCheck

function posthasteCatCheck()
{
    if (is_category()) {
        return get_cat_ID(single_cat_title('', false));
    } else {
        return get_option('default_category', 1);
    }
}
开发者ID:smajda,项目名称:posthaste,代码行数:8,代码来源:posthaste.php

示例13: alaya_cat_slug

function alaya_cat_slug($cate_name)
{
    $cat_ID = get_cat_ID($cate_name);
    $thisCat = get_category($cat_ID);
    $cat_slug = $thisCat->slug;
    $cat_slug = apply_filters('alaya_cat_slug', $cat_slug);
    return $cat_slug;
}
开发者ID:jasmith93,项目名称:cnws,代码行数:8,代码来源:lib.php

示例14: get_my_category_link

function get_my_category_link($categoryName)
{
    // Get the ID of a given category
    $category_id = get_cat_ID($categoryName);
    // Get the URL of this category
    $category_link = get_category_link($category_id);
    return $category_link;
}
开发者ID:KaiYangCHN,项目名称:WordPress,代码行数:8,代码来源:functions.php

示例15: tfuse_shortcode_posts

 /**
  *  Generate array with: recent/popular/most commented posts
  * @param string $sort Sort type (recent/popular/most commented)
  * @param integer $items Number of items to be extracted
  * @param boolean $image_post Extract or no post image
  * @param integer $image_width Set width of post image
  * @param integer $image_height Set height of post image
  * @param string $image_class Set class of post image
  * @param boolean $date_post Extract or no post date
  * @param string $date_format Set date format
  * @param string $post_type Set post type
  * @param string $category Set category from where posts would be extracted
  * @since Medica 2.0
  */
 function tfuse_shortcode_posts($args = null)
 {
     $defaults = array('sort' => 'recent', 'items' => 5, 'image_post' => true, 'image_width' => 54, 'image_height' => 54, 'image_class' => 'thumbnail', 'date_post' => true, 'date_format' => 'F jS, Y', 'post_type' => 'post', 'category' => '', 'specialites' => '');
     extract(wp_parse_args($args, $defaults));
     global $post;
     $tf_cat_ID = !empty($category) && empty($specialites) ? get_cat_ID($category) : '';
     $specialites = empty($category) && !empty($specialites) ? $specialites : '';
     if ($sort == 'recent') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'post_date', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'Specialites' => $specialites, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'popular') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'meta_value', 'meta_key' => TF_THEME_PREFIX . '_post_viewed', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'commented') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'comment_count', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } else {
         return false;
     }
     $tf_post_option = array();
     $count = 0;
     if (!empty($posts)) {
         foreach ($posts as $post_elm) {
             setup_postdata($post_elm);
             $img = '';
             if ($image_post == true) {
                 $post_image_src = tfuse_page_options('thumbnail_image', tfuse_page_options('single_image', null, $post_elm->ID), $post_elm->ID);
                 if (!empty($post_image_src)) {
                     $get_image = new TF_GET_IMAGE();
                     $img = $get_image->properties(array('class' => $image_class, 'alt' => get_the_title($post_elm->ID)))->width($image_width)->height($image_height)->src($post_image_src)->resize(true)->get_img();
                 }
             }
             if (!empty($img)) {
                 $tf_post_option[$count]['post_img'] = $img;
             } else {
                 $tf_post_option[$count]['post_img'] = '';
             }
             if ($date_post) {
                 $time_format = apply_filters('tfuse_widget_time_format', $date_format);
                 $tf_post_option[$count]['post_date_post'] = get_the_time($time_format, $post_elm->ID);
             } else {
                 $tf_post_option[$count]['post_date_post'] = '';
             }
             $tf_post_option[$count]['post_class'] = is_singular() && $post->ID == $post_elm->ID ? 'current-menu-item post_' . $sort : 'post_' . $sort;
             $tf_post_option[$count]['post_title'] = get_the_title($post_elm->ID);
             $tf_post_option[$count]['post_link'] = get_permalink($post_elm->ID);
             $tf_post_option[$count]['post_author_link'] = get_author_posts_url(get_the_author_meta('ID'));
             $tf_post_option[$count]['post_author_name'] = get_the_author();
             $tf_post_option[$count]['post_comnt_numb'] = get_comments_number($post_elm->ID);
             $tf_post_option[$count]['post_comnt_numb_link'] = tfuse_get_comments(true, $post_elm->ID);
             $tf_post_option[$count]['post_loveit_number'] = get_post_meta($post_elm->ID, TF_THEME_PREFIX . '_post_viewed', true);
             $tf_post_option[$count]['post_excerpt'] = apply_filters('get_the_excerpt', $post_elm->post_excerpt);
             $count++;
         }
         wp_reset_postdata();
     }
     return $tf_post_option;
 }
开发者ID:shimion,项目名称:stlucks,代码行数:72,代码来源:SHOTCODE_POSTS.php


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