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

PHP get_category_link函数代码示例

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

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



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

示例1: inti_get_categories_meta

 function inti_get_categories_meta($args = '')
 {
     $count = 0;
     $categories_list = '';
     $categories = get_the_category();
     foreach ($categories as $category) {
         $count++;
         if ($args['show_uncategorized']) {
             $categories_list .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__('View all posts in %s', 'inti'), $category->name) . '"><span class="label category">' . $category->name . '</span></a>';
             if ($count != count($categories)) {
                 $categories_list .= ' ';
                 //separator
             }
         } else {
             if ($category->slug != 'uncategorized' || $category->name != 'Uncategorized') {
                 $categories_list .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__('View all posts in %s', 'inti'), $category->name) . '"><span class="label category">' . $category->name . '</span></a>';
                 if ($count != count($categories)) {
                     $categories_list .= ' ';
                     //separator
                 }
             }
         }
     }
     return $categories_list;
 }
开发者ID:waqastudios,项目名称:inti-foundation,代码行数:25,代码来源:post-meta.php


示例2: CTF_snippet

function CTF_snippet($atts)
{
    extract(shortcode_atts(array('category' => '', 'link' => '', 'date' => '', 'dofollow' => FALSE), $atts));
    global $post;
    $snippet = "{$postid}<div class=\"ctf-snippet\">";
    $snippet .= "<span class=\"ctf-title\">CTF:</span> <span class=\"ctf-value\">";
    if (empty($category)) {
        //Default category (1st category)
        $snippet .= "<a href=\"" . get_category_link(get_the_category($post->ID)[0]->cat_ID) . "\" rel=\"category tag\">" . get_the_category($post->ID)[0]->name . "</a>";
    } else {
        $snippet .= $category;
    }
    $snippet .= "</span>";
    $snippet .= "<br />";
    $snippet .= "<span class=\"ctf-title\">Link to challenge:</span> <span class=\"ctf-value\">";
    //Generate link
    if (!empty($link)) {
        $snippet .= "<a href=\"{$link}\" rel=\"external";
        if (!$dofollow) {
            $snippet .= " nofollow";
        }
        $pu = parse_url($link);
        $link_base = $pu["scheme"] . "://" . $pu["host"];
        $snippet .= "\">{$link_base}</a>";
        $snippet .= "<img class=\"external_url\" src=\"" . get_stylesheet_directory_uri() . "/images/external-link.png\" />";
    } else {
        $snippet .= "N/A";
    }
    $snippet .= "</span><br />";
    //Date of completion
    $snippet .= "<span class=\"ctf-title\">Date Completed:</span> <span class=\"ctf-value\">{$date}</span>";
    $snippet .= "</div>";
    return $snippet;
}
开发者ID:mohammadg,项目名称:CTF-Snippet-Inserter,代码行数:34,代码来源:ctf-snippet-insert.php


示例3: the_breadcrumb

function the_breadcrumb()
{
    global $post;
    if (!is_home()) {
        echo '<div class="main_breadcrum"><p><a href="'. get_option('home') .'"> Home </a> > ';
        if ( is_category() || is_single() ) {
            foreach( ( get_the_category() ) as $category ) {
                if ( $category->cat_name != 'Slider' ) {
                    echo '<a href="'. get_category_link( $category->term_id ) .'" title="'. $category->name .'" ' . '>'. $category->name .'</a> ';
                }
            }
            echo '</p></div>'; 
        } elseif ( is_page() ) {
            if( $post->post_parent ){
                $result = get_post_ancestors( $post->ID );
                $title = get_the_title();
                $output = '';
                $anc = array_reverse( $result );
                foreach ( $anc as $ancestor ) {
                    $output .= '<a href="'. get_permalink( $ancestor ) .'" title="'. get_the_title( $ancestor ) .'">'.get_the_title( $ancestor ) .'</a> > ';
                }
                echo $output;
                echo '<strong title="'. $title .'"> '. $title .'</strong></p></div>';
            } else {
                echo '<strong> '. get_the_title() .'</strong></p></div>';
            }
        }
    }
}
开发者ID:plusinterativa,项目名称:clientes,代码行数:29,代码来源:functions.php


示例4: widget

 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  * @since 1.0.0
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 function widget($args, $instance)
 {
     // Extract args
     extract($args, EXTR_SKIP);
     $category_id = empty($instance['category_id']) ? 1 : $instance['category_id'];
     $use_cat_title = empty($instance['use_cat_title']) ? 0 : $instance['use_cat_title'];
     $hide_empty_cats = empty($instance['hide_empty_cats']) ? 0 : $instance['hide_empty_cats'];
     $show_post_count = empty($instance['show_post_count']) ? 0 : $instance['show_post_count'];
     $title_link = empty($instance['title_link']) ? 0 : $instance['title_link'];
     if ($use_cat_title) {
         $title = apply_filters('widget_title', get_cat_name($category_id), $instance, $this->id_base);
     } else {
         $title = apply_filters('widget_title', empty($instance['title']) ? __('Sub Categories', 'wpsp') : $instance['title'], $instance, $this->id_base);
     }
     $no_sub_text = '<p>' . __('No sub-categories', 'wpsp') . '</p>';
     $subs = wp_list_categories(array('child_of' => $category_id, 'hide_empty' => $hide_empty_cats, 'show_count' => $show_post_count, 'title_li' => null, 'show_option_none' => '', 'echo' => 0));
     echo $before_widget;
     if ($title_link) {
         echo $before_title . '<a href="' . get_category_link($category_id) . '">' . $title . '</a>' . $after_title;
     } else {
         echo $before_title . $title . $after_title;
     }
     if (!empty($subs)) {
         echo '<ul>' . $subs . '</ul>';
     } else {
         echo $no_sub_text;
     }
     echo $after_widget;
     return $instance;
 }
开发者ID:sptheme,项目名称:klahan9,代码行数:39,代码来源:sub-categories-widget.php


示例5: loop_category

function loop_category($category)
{
    $idObj = get_category_by_slug($category);
    $cat_name = $idObj->name;
    if ($category === 'news') {
        $number = 4;
    } else {
        $number = 1;
    }
    $args = array('posts_per_page' => $number, 'category_name' => $category);
    $posts_array = get_posts($args);
    $length = count($posts_array);
    if ($length > 0) {
        echo '<a href="' . get_category_link($idObj->cat_ID) . ' " ><h3 class="big-article-title">' . $cat_name . '</h3></a>';
        global $post;
        foreach ($posts_array as $key => $post) {
            setup_postdata($post);
            if ($key === 0) {
                get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format());
            } else {
                if ($key === 1) {
                    echo '<ul class="other-post-list length' . ($length - 1) . '">';
                }
                get_template_part('templates/content', 'post-intro');
                if ($key === $length) {
                    echo '</ul>';
                }
            }
        }
        wp_reset_postdata();
    }
}
开发者ID:Kilbourne,项目名称:bedrock,代码行数:32,代码来源:extras.php


示例6: widget

    function widget($args, $instance)
    {
        extract($args);
        $title = empty($instance['title']) ? '' : $instance['title'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<ul class="media-list">
			<?php 
        $args = array('hierarchical' => false, 'pad_counts' => true, 'parent' => 0, 'orderby' => 'count', 'order' => 'DESC');
        $topCat = get_categories($args);
        foreach ($topCat as $category) {
            $attrImg = array('class' => 'pull-left', 'alt' => 'Logo ' . $category->name, 'height' => 40, 'width' => 40, 'title' => $category->name);
            echo '<li class="media"><div class="media-left"><a title="' . $category->name . '" class="media-heading" href="' . get_category_link($category->term_id) . '">';
            z_taxonomy_image($category->term_id, array(40, 40, true), $attrImg);
            echo '</a></div><div class="media-body media-middle">';
            echo '<a title="' . $category->name . '" class="media-heading" href="' . get_category_link($category->term_id) . '">' . $category->name . ' <span class="badge">' . $category->count . '</span></a>';
            echo '</div></li>';
        }
        ?>
		</ul>

	<?php 
        echo $after_widget;
    }
开发者ID:plaurent75,项目名称:Categories-Images-Widget,代码行数:27,代码来源:widget-catimage.php


示例7: get_category

 function get_category()
 {
     $buffy = '';
     //read the post meta to get the custom primary category
     $td_post_theme_settings = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
     if (!empty($td_post_theme_settings['td_primary_cat'])) {
         //we have a custom category selected
         $selected_category_obj = get_category($td_post_theme_settings['td_primary_cat']);
     } else {
         //get one auto
         $categories = get_the_category($this->post->ID);
         if (!empty($categories[0])) {
             if ($categories[0]->name === TD_FEATURED_CAT and !empty($categories[1])) {
                 $selected_category_obj = $categories[1];
             } else {
                 $selected_category_obj = $categories[0];
             }
         }
     }
     if (!empty($selected_category_obj)) {
         //@todo catch error here
         $buffy .= '<a href="' . get_category_link($selected_category_obj->cat_ID) . '">' . $selected_category_obj->name . '</a>';
     }
     //return print_r($post, true);
     return $buffy;
 }
开发者ID:luxifel,项目名称:Bionerd,代码行数:26,代码来源:td_module_slide.php


示例8: widget

    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $category_id = empty($instance['category_id']) ? 1 : $instance['category_id'];
        $use_cat_title = empty($instance['use_cat_title']) ? 0 : $instance['use_cat_title'];
        $hide_empty_cats = empty($instance['hide_empty_cats']) ? 0 : $instance['hide_empty_cats'];
        $show_post_count = empty($instance['show_post_count']) ? 0 : $instance['show_post_count'];
        $title_link = empty($instance['title_link']) ? 0 : $instance['title_link'];
        $excluded = empty($instance['excluded']) ? '' : $instance['excluded'];
        $sub_subs = empty($instance['sub_subs']) ? 0 : $instance['sub_subs'];
        $dropdown = empty($instance['dropdown']) ? 0 : $instance['dropdown'];
        $post_is_parent = empty($instance['post_is_parent']) ? 0 : $instance['post_is_parent'];
        $dropdown_text = empty($instance['dropdown_text']) ? __('Select Sub-category', 'sub-categories-widget') : $instance['dropdown_text'];
        $list_order = empty($instance['list_order']) ? 0 : $instance['list_order'];
        if ($post_is_parent) {
            $category = get_the_category();
            $category_id = $category ? $category[0]->cat_ID : 1;
        }
        if ($use_cat_title) {
            $title = apply_filters('widget_title', get_cat_name($category_id), $instance, $this->id_base);
        } else {
            $title = apply_filters('widget_title', empty($instance['title']) ? __('Sub Categories', 'sub-categories-widget') : $instance['title'], $instance, $this->id_base);
        }
        $parent = $sub_subs == 1 ? 'child_of' : 'parent';
        $order = $list_order == 1 ? 'DESC' : 'ASC';
        $no_sub_text = '<p>' . __('No sub-categories', 'sub-categories-widget') . '</p>';
        $subs = wp_list_categories(array($parent => $category_id, 'hide_empty' => $hide_empty_cats, 'show_count' => $show_post_count, 'exclude' => $excluded, 'title_li' => null, 'show_option_none' => '', 'echo' => 0, 'orderby' => 'ID', 'order' => $order));
        if ($post_is_parent == 0 || $post_is_parent == 1 && !empty($subs)) {
            echo $before_widget;
            if ($title_link) {
                echo $before_title . '<a href="' . get_category_link($category_id) . '">' . $title . '</a>' . $after_title;
            } else {
                echo $before_title . $title . $after_title;
            }
            if ($dropdown == 0) {
                if (!empty($subs)) {
                    echo '<ul>' . $subs . '</ul>';
                } else {
                    echo $no_sub_text;
                }
            } else {
                $subs = wp_dropdown_categories(array('id' => 'sub-cat-' . $this->number, 'show_option_none' => $dropdown_text, $parent => $category_id, 'hide_empty' => $hide_empty_cats, 'show_count' => $show_post_count, 'exclude' => $excluded, 'hide_if_empty' => true, 'echo' => false, 'orderby' => 'ID', 'order' => $order));
                if (!empty($subs)) {
                    echo $subs;
                    echo '<script type="text/javascript">
						/* <![CDATA[ */
						var dropdown' . $this->number . ' = document.getElementById("sub-cat-' . $this->number . '");
						function onSubCatChange() {
						if (dropdown' . $this->number . '.options[dropdown' . $this->number . '.selectedIndex].value > 0) { location.href = "' . get_option('home') . '?cat="+dropdown' . $this->number . '.options[dropdown' . $this->number . '.selectedIndex].value; }
						}
						dropdown' . $this->number . '.onchange = onSubCatChange;
						/* ]]> */
						</script>';
                } else {
                    echo $no_sub_text;
                }
            }
            echo $after_widget;
        }
    }
开发者ID:phongvan212,项目名称:kinhte,代码行数:60,代码来源:sub-categories-widget.php


示例9: widget

 function widget($args, $instance)
 {
     extract($args);
     $c = $instance['count'] ? '1' : '0';
     $archive_type = $instance['archive_type'] ? '1' : '0';
     $title = apply_filters('widget_title', __('Archives', 'unspoken'));
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if ($archive_type == 0) {
         $categories = get_categories();
         $output = '<ul>';
         foreach ($categories as $category) {
             $output .= sprintf('<li><a href="%1$s" title="%2$s">%3$s</a><span>%4$s</span></li>', get_category_link($category->term_id), sprintf(__('View all posts in %s', 'unspoken'), $category->name), $category->name, $c ? $category->count : '');
         }
         $output .= '</ul>';
     } else {
         global $wpdb, $wp_locale;
         // set limit for list
         $archive_limit = 0;
         // query
         $q = "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', COUNT(ID) as post_count " . "FROM {$wpdb->posts} " . "WHERE post_type = 'post' AND post_status = 'publish' " . "GROUP BY month, year " . "ORDER BY post_date DESC" . ($archive_limit == 0 ? '' : ' LIMIT ' . $archive_limit);
         // make query for result
         $months = $wpdb->get_results($q);
         $output = '<ul>';
         // looping through result
         foreach ($months as $month) {
             $output .= sprintf('<li><a href="%1$s">%2$s<span>%3$s</span></a></li>', get_month_link($month->year, $month->month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month->month), $month->year), $c ? $month->post_count : '');
         }
         $output .= '</ul>';
     }
     echo $output;
     echo $after_widget;
 }
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:35,代码来源:archive.php


示例10: _meta_data

 private function _meta_data($view, $params)
 {
     $defaults = array('class' => '');
     $params = wp_parse_args($params, $defaults);
     $content = '';
     // Date
     $content .= '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" class="blog_date"><i class="icon-calendar"></i>' . get_the_date('F j, Y') . '</a>';
     // Categories
     $post_categories = wp_get_post_categories(get_the_ID());
     $categories = array();
     foreach ($post_categories as $c) {
         $cat = get_category($c);
         $categories[] = '<a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a>';
     }
     if (count($categories) > 0) {
         $content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $categories) . '</div>';
     }
     // Author
     $content .= '<span class="blog_author"><i class="icon-user"></i>' . get_the_author() . '</span>';
     $post_tags = wp_get_post_tags(get_the_ID());
     $tags = array();
     foreach ($post_tags as $tag) {
         $tags[] = '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>';
     }
     if (count($tags) > 0) {
         $content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $tags) . '</div>';
     }
     return '<div class="' . $params['class'] . '">' . $content . '</div>';
 }
开发者ID:ashanrupasinghe,项目名称:amc-car-from-server-2015-1-14,代码行数:29,代码来源:post_widget.php


示例11: widget

 function widget($args, $instance)
 {
     /* Get title */
     $args['title'] = $instance['title'];
     /* If empty, default */
     if (!$args['title']) {
         $args['title'] = 'Popular Categorys';
     }
     /* Get nnpopularcats */
     $args['npopularcats'] = $instance['npopularcats'];
     /* If empty, default 10 */
     if (!$args['npopularcats']) {
         $args['npopularcats'] = 10;
     }
     /* Get popular cats */
     global $wpdb;
     $query = "SELECT a.name, a.slug, b.term_id, b.count FROM {$wpdb->term_taxonomy} b\n    \t\t\tLEFT JOIN {$wpdb->terms} a\n    \t\t\tON b.term_id = a.term_id\n    \t\t\tWHERE b.taxonomy = 'category'\n    \t\t\tORDER BY b.count DESC\n    \t\t\tLIMIT " . $args['npopularcats'];
     $get_categories = $wpdb->get_results($query);
     // Prepare cats list
     $list = '<ul class="popular-category-list">';
     foreach ($get_categories as $cat) {
         $list .= '<li><a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a></li>';
     }
     $list .= '</ul>';
     // Print everything
     echo $args['before_widget'] . $args['before_title'] . $args['title'] . $args['after_title'];
     echo $list;
     echo $args['after_widget'];
 }
开发者ID:recetasdemama,项目名称:recetasdemama-theme,代码行数:29,代码来源:cat-populares.php


示例12: run_menu

function run_menu()
{
    $Menu = [];
    $args = array('orderby' => 'name', 'parent' => 0);
    $categories = get_categories($args);
    foreach ($categories as $key => $category) {
        $children = get_terms($category->taxonomy, array('parent' => $category->term_id, 'hide_empty' => false));
        if ($children) {
            $genre = $category->name;
            $list = '<li class="has-children"><a href="#0">' . $genre . '</a><ul class="is-hidden here"><li class="go-back"><a href="#0">' . $genre . '</a></li><li class="see-all"><a href="' . get_category_link($category->term_id) . '">All ' . $genre . '</a></li>';
            $ChildCats = get_categories('child_of=' . $category->cat_ID);
            foreach ($ChildCats as $ChildCat) {
                $option = '<li><a href="' . get_category_link($ChildCat->term_id) . '">';
                $option .= $ChildCat->cat_name;
                $option .= '</a></li>';
                $list .= $option;
            }
            $list .= '</ul></li>';
        } else {
            $list = '<li><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
        }
        $Menu[] = $list;
    }
    return $Menu;
    //print_r($Menu);
}
开发者ID:allenahner,项目名称:wp,代码行数:26,代码来源:functions.php


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


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


示例15: categories

 /**
  * Get the categories attached to this post
  * @return array
  */
 public function categories()
 {
     $categories = get_the_category($this->wp_post);
     return array_map(function ($category) {
         return (object) array_merge((array) $category, ['url' => get_category_link($category->term_id)]);
     }, $categories);
 }
开发者ID:laraish,项目名称:laraish,代码行数:11,代码来源:Post.php


示例16: start_el

 function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
 {
     if (!isset($td_last_category_objects[$depth])) {
         $this->td_category_hierarchy[$depth] = $category;
     }
     if ($depth == 0) {
         //reset the parrents
         $this->td_category_hierarchy = array();
         //put the
         $this->td_category_hierarchy[0] = $category;
         //add first parent
         $this->td_category_buffer['<a href="' . get_category_link($category->term_id) . '" target="_blank" data-is-category-link="yes">' . $category->name . '</a>'] = $category->term_id;
     } else {
         $td_tmp_buffer = '';
         $last_cat_id = 0;
         foreach ($this->td_category_hierarchy as $parent_cat_obj) {
             if ($td_tmp_buffer === '') {
                 $td_tmp_buffer = '<a href="' . get_category_link($parent_cat_obj->term_id) . '" target="_blank" data-is-category-link="yes">' . $parent_cat_obj->name . '</a>';
                 $last_cat_id = $parent_cat_obj->term_id;
             } else {
                 $td_tmp_buffer .= '<img src="' . get_template_directory_uri() . '/wp-admin/images/panel/panel-breadcrumb.png" class="td-panel-breadcrumb">' . '<a href="' . get_category_link($parent_cat_obj->term_id) . '" target="_blank" data-is-category-link="yes">' . $parent_cat_obj->name . '</a>';
                 $last_cat_id = $parent_cat_obj->term_id;
             }
         }
         //add child
         $this->td_category_buffer[$td_tmp_buffer] = $last_cat_id;
     }
 }
开发者ID:Vatia13,项目名称:wordpress,代码行数:28,代码来源:panel_categories.php


示例17: categories_cloud

/**
* @desc weighted categories cloud with options for fontsize, color, after html, before html, exludecategories
* @param int $smallest	- fontsize of the smallest category
* @param int $largest	- fontsize of the largest category
* @param string $unit	- unit for the fontsize % / px /
* @param string $cold 	- fontcolor for the coldest cat
* @param string $hot 	- fontcolor for the hottest cat
* @param string $before	- html before each cat link
* @param string $after 	- html after each cat link
* @param string $exclude- categories to exclude as comma seperated list
* @author george leciejewski / Christoph Wimmer
*/
function categories_cloud($smallest = 50, $largest = 200, $unit = "%", $cold = "", $hot = "", $before = '', $after = '', $exclude = '')
{
    global $wpdb;
    $exclusions = '';
    if (!empty($exclude)) {
        # set excluded category ids for sql
        $excats = preg_split('/[\\s,]+/', $exclude);
        if (count($excats)) {
            foreach ($excats as $excat) {
                $exclusions .= ' AND ' . $wpdb->categories . '.cat_ID <> ' . intval($excat) . ' ';
            }
        }
    }
    # returns the categories as objects $result->post, id, name, nicename
    $results = $wpdb->get_results('SELECT ' . $wpdb->categories . '.cat_ID AS `id`,' . $wpdb->categories . '.cat_name AS `name`,' . $wpdb->categories . '.category_nicename AS `nicename`' . ',COUNT(' . $wpdb->post2cat . '.rel_id) AS `posts` FROM ' . $wpdb->categories . ', ' . $wpdb->post2cat . ' WHERE ' . $wpdb->categories . '.cat_ID = ' . $wpdb->post2cat . '.category_id' . $exclusions . ' GROUP BY ' . $wpdb->categories . '.cat_ID ORDER BY cat_name ASC');
    $content = array();
    foreach ($results as $key => $val) {
        # normalize the values to fit into KingCloud Class content var
        $content[$key]['url'] = get_category_link($val->id);
        $content[$key]['text'] = stripslashes($val->name);
        $content[$key]['title'] = $val->posts . ' Artikel';
        $content[$key]['count'] = $val->posts;
    }
    $cloud = new KingCloud($content, $smallest, $largest, $unit, $cold, $hot, $before, $after);
    $cloud->output();
}
开发者ID:jbogota,项目名称:blog-king,代码行数:38,代码来源:king_clouds.php


示例18: get_block_sub_cats

 function get_block_sub_cats($atts)
 {
     extract(shortcode_atts(array('limit' => 5, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'show_child_cat' => '', 'sub_cat_ajax' => ''), $atts));
     $buffy = '';
     if (!empty($show_child_cat) and !empty($category_id)) {
         $td_subcategories = get_categories(array('child_of' => $category_id));
         if (!empty($td_subcategories)) {
             if ($show_child_cat != 'all') {
                 $td_subcategories = array_slice($td_subcategories, 0, $show_child_cat);
             }
             $buffy .= '<div class="block-mega-child-cats">';
             //show all categories only on ajax
             if (empty($sub_cat_ajax)) {
                 $buffy .= '<div><a class="cur-sub-cat ajax-sub-cat-mega sub-cat-' . $this->block_uid . '" id="sub-cat-' . $this->block_uid . '-' . $category_id . '" data-cat_id="' . $category_id . '"
                     data-td_block_id="' . $this->block_uid . '" href="' . get_category_link($category_id) . '">' . __td('All') . '</a></div>';
             }
             foreach ($td_subcategories as $td_category) {
                 if (empty($sub_cat_ajax)) {
                     $buffy .= '<div><a class="ajax-sub-cat-mega sub-cat-' . $this->block_uid . '" id="sub-cat-' . $this->block_uid . '-' . $td_category->cat_ID . '" data-cat_id="' . $td_category->cat_ID . '" data-td_block_id="' . $this->block_uid . '" href="' . get_category_link($td_category->cat_ID) . '">' . $td_category->name . '</a></div>';
                 } else {
                     $buffy .= '<div><a href="' . get_category_link($td_category->cat_ID) . '">' . $td_category->name . '</a></div>';
                 }
             }
             $buffy .= '</div>';
         } else {
             //there are no subcategories, return false - this is used by the mega menu block to alter it's structure
             return false;
         }
     }
     return $buffy;
 }
开发者ID:Vatia13,项目名称:wordpress,代码行数:31,代码来源:td_block_mega_menu.php


示例19: list_categories_from_current_blog_post

function list_categories_from_current_blog_post()
{
    $postCats = get_the_category();
    if ($postCats) {
        ?>
    	
      <h5>Catorgories</h5>

      <ul>

      <?php 
        //the_terms($post->ID,"service_type", '', ', ', ' ');
        ?>

      <?php 
        //customPostTypeCatList('post');
        $separator = '';
        $output = '';
        if ($postCats) {
            foreach ($postCats as $category) {
                $output .= '<li><a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '">' . $category->cat_name . '</a></li>' . $separator;
            }
            echo trim($output, $separator);
        }
    }
    echo '</ul>';
}
开发者ID:pixelstorm,项目名称:nav_systems,代码行数:27,代码来源:get_cat_from_current_blog_post.php


示例20: widget

 function widget($args, $instance)
 {
     extract($args);
     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
     $limit = is_numeric($instance['limit']) ? $instance['limit'] : 5;
     $orderby = $instance['orderby'] ? $instance['orderby'] : 'date';
     $order = $instance['order'] ? $instance['order'] : 'desc';
     $exclude = $instance['exclude'] != '' ? $instance['exclude'] : 0;
     $excludeposts = $instance['excludeposts'] != '' ? $instance['excludeposts'] : 0;
     $offset = is_numeric($instance['offset']) ? $instance['offset'] : 0;
     $category_id = $instance['categoryid'];
     $dateformat = $instance['dateformat'] ? $instance['dateformat'] : get_option('date_format');
     $showdate = $instance['show_date'] == 'on' ? 'yes' : 'no';
     $showexcerpt = $instance['show_excerpt'] == 'on' ? 'yes' : 'no';
     $excerptsize = empty($instance['excerpt_size']) ? 55 : $instance['excerpt_size'];
     $showauthor = $instance['show_author'] == 'on' ? 'yes' : 'no';
     $showcatlink = $instance['show_catlink'] == 'on' ? 'yes' : 'no';
     $thumbnail = $instance['thumbnail'] == 'on' ? 'yes' : 'no';
     $thumbnail_size = $instance['thumbnail_size'] ? $instance['thumbnail_size'] : 'thumbnail';
     $morelink = empty($instance['morelink']) ? ' ' : $instance['morelink'];
     $atts = array('id' => $category_id, 'orderby' => $orderby, 'order' => $order, 'numberposts' => $limit, 'date' => $showdate, 'author' => $showauthor, 'dateformat' => $dateformat, 'template' => 'default', 'excerpt' => $showexcerpt, 'excerpt_size' => $excerptsize, 'exclude' => $exclude, 'excludeposts' => $excludeposts, 'offset' => $offset, 'catlink' => $showcatlink, 'thumbnail' => $thumbnail, 'thumbnail_size' => $thumbnail_size, 'morelink' => $morelink);
     echo $before_widget;
     if ($title == 'catlink') {
         //if the user has setup 'catlink' as the title, replace it with the category link:
         $lcp_category = get_category($category_id);
         $title = '<a href="' . get_category_link($lcp_category->cat_ID) . '">' . $lcp_category->name . '</a>';
     }
     echo $before_title . $title . $after_title;
     $catlist_displayer = new CatListDisplayer($atts);
     echo $catlist_displayer->display();
     echo $after_widget;
 }
开发者ID:kivivuori,项目名称:jotain,代码行数:32,代码来源:ListCategoryPostsWidget.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_category_list函数代码示例发布时间:2022-05-15
下一篇:
PHP get_category_info函数代码示例发布时间: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