• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_cat_ID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: related_posts

function related_posts()
{
    echo "<h3 class=\"dividing-title\">Oglejte si še</h3>";
    $rp_prikazani[0] = get_the_ID();
    //ID glavnega posta, da se ne ponovi v predlogih
    global $post;
    $rp_x = 0;
    //Štetje, koliko postov je bilo izpisanih
    $rp_relacije = get_field('relacije');
    //Funkcija od Advanced custom fields plugina, no plugin no FUN
    //Izpiši ročno izbrane poste
    if ($rp_relacije) {
        $rp_args = array('post__in' => $rp_relacije);
        $rp_post_array = get_posts($rp_args);
        foreach ($rp_post_array as $post) {
            setup_postdata($post);
            rp_izpis();
            $rp_prikazani[$rp_x + 1] = get_the_ID();
            $rp_x++;
        }
        wp_reset_postdata();
    }
    //Če niso izbrani 4 posti, poišči dodatne, glede na kategorijo ali tag
    if ($rp_x < 4) {
        $rp_categories = get_the_category();
        foreach ($rp_categories as $rp_category) {
            if ($rp_category->term_id != get_cat_ID("prva_stran1") and $rp_category->term_id != get_cat_ID("prva_stran2") and $rp_category->term_id != get_cat_ID("prva_stran3") and $rp_category->term_id != get_cat_ID("slider")) {
                $rp_cat_list[] = $rp_category->term_id;
            }
        }
        $rp_oznake = get_the_tags();
        $rp_tag_list = array();
        if (is_array($rp_oznake)) {
            foreach ($rp_oznake as $rp_oznaka) {
                $rp_tag_list[] = $rp_oznaka->term_id;
            }
        }
        $rp_args = array('posts_per_page' => 6 - $rp_x, 'offset' => 0, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'suppress_filters' => true, 'tax_query' => array('relation' => 'OR', array('taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => $rp_tag_list), array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => $rp_cat_list)));
        $rp_post_array = get_posts($rp_args);
        foreach ($rp_post_array as $post) {
            setup_postdata($post);
            $rp_cid = get_the_ID();
            //Preveri, če je post že prikazan in v tem primeru postavi $rp_y = 0
            $rp_y = 1;
            foreach ($rp_prikazani as $rp_i) {
                if ($rp_i == $rp_cid) {
                    $rp_y = 0;
                }
            }
            //Preveri, če bo post izpisan
            if ($rp_x < 4 && $rp_y) {
                rp_izpis();
                $rp_x++;
            }
        }
        wp_reset_postdata();
    }
}
开发者ID:polhec,项目名称:related_posts_mon,代码行数:58,代码来源:index.php


示例17: build_jsonldBreadcrumb

 function build_jsonldBreadcrumb()
 {
     $jsonLD["@context"] = "http://schema.org/";
     $jsonLD["@type"] = "BreadcrumbList";
     //---------------------------------
     // pre-define some variables
     //---------------------------------
     $home_title = get_bloginfo('name');
     $home_url = esc_url(home_url('/'));
     $blog_url = get_permalink(get_option('page_for_posts'));
     $blog_title = get_the_title(get_option('page_for_posts', true));
     $url = $url ? $url : get_permalink();
     $title = $title ? $title : get_the_title();
     $itemList = array();
     //----------------------------------
     // Output
     //-----------------------------------
     $itemList[] = array("@type" => "ListItem", "position" => 1, "item" => array('@id' => $home_url, 'name' => $home_title));
     //----------------------------------------------
     // figure out the next number
     // <meta property="position" content="{NUM}">
     //----------------------------------------------
     $next = 2;
     if (is_single() or is_home()) {
         //-------------------------------------
         // we have a blog "post"
         // so we added the blog url (not home)
         // so next is 3 not 2!
         //--------------------------------------
         $itemList[] = array("@type" => "ListItem", "position" => 2, "item" => array('@id' => $blog_url, 'name' => $blog_title));
         $next = 3;
     }
     if (is_single() or is_page() or is_tag() or is_category()) {
         //----------------------------------
         // is it a tag?
         //----------------------------------
         if (is_tag()) {
             $title = single_tag_title("", false);
             $tag_id = get_term_by('name', $title, 'post_tag');
             $url = get_tag_link($tag_id->term_id);
         }
         if (is_category()) {
             $title = single_cat_title("", false);
             $category_id = get_cat_ID($title);
             $url = get_category_link($category_id);
         }
         $itemList[] = array("@type" => "ListItem", "position" => $next, "item" => array('@id' => $url, 'name' => $title));
     }
     $jsonLD["itemListElement"] = $itemList;
     /*echo '<pre>';
     	print_r(json_encode($jsonLD));
     	echo '</pre>';*/
     if ((is_page() or is_single() or is_home() or is_tag() or is_category()) and !is_front_page()) {
         echo '<script type="application/ld+json">';
         echo json_encode($jsonLD);
         echo '</script>';
     }
 }
开发者ID:AmgedOsman,项目名称:wordpress-json-ld,代码行数:58,代码来源:functions.php


示例18: load

 /**
  * Load template
  *
  * @param Int $offset number off for pagination
  *
  * @return void
  */
 public static function load($offset = 0, $category = 0)
 {
     $category = get_cat_ID($category);
     $offset = $offset;
     if (0 === $category) {
         $category = get_the_category()[0]->cat_ID;
     }
     require get_stylesheet_directory() . self::PATH;
 }
开发者ID:jsoningram,项目名称:offgrid-framework,代码行数:16,代码来源:Generator.php


示例19: get_category_name_link

function get_category_name_link($strName, $strDisplay = '')
{
    $strResult = '';
    if ($strDisplay == '') {
        $strDisplay = $strName;
    }
    $strResult = '<a href="' . get_category_link(get_cat_ID($strName)) . '">' . $strDisplay . '</a>';
    return $strResult;
}
开发者ID:powettv,项目名称:powettv-theme-3,代码行数:9,代码来源:functions.php


示例20: de_create_featured_post

function de_create_featured_post()
{
    if (get_option('is_featured_post_sample') != 'true') {
        // Create post object
        $my_post = array('post_title' => 'Featured Post Sample', 'post_content' => 'This is just a sample post, Edit or delete it.', 'post_status' => 'publish', 'post_author' => 1, 'post_category' => array(get_cat_ID("featured post")));
        // Insert the post into the database
        wp_insert_post($my_post);
        add_option("is_featured_post_sample", 'true');
    }
}
开发者ID:JerryXie96,项目名称:PBSMUNC2013WebSite,代码行数:10,代码来源:db.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_cat_articles函数代码示例发布时间:2022-05-15
下一篇:
PHP get_cat函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap