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


PHP get_tag_link函数代码示例

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


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

示例1: widget

 function widget($args, $instance)
 {
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $title = !empty($instance['title']) ? $instance['title'] : '';
     if (is_singular('post') && has_tag()) {
         global $post;
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo $title;
             echo $after_title;
         }
         echo '<div class="tagcloud">';
         $tags = wp_get_post_tags($post->ID);
         foreach ($tags as $t => $tag) {
             echo '<a href="' . get_tag_link($tag->term_id) . '" title="' . $tag->count . ' topic">';
             echo $tag->name;
             echo '</a>';
         }
         echo '<div class="clear"></div>';
         echo '</div>';
         echo $after_widget;
     }
 }
开发者ID:mathieu-aubin,项目名称:verbo-linuq,代码行数:25,代码来源:my_wdg_post_tags.php

示例2: ungarh_tag_list

/**
 * News child tags
 */
function ungarh_tag_list()
{
    //get all the options that we want to show
    global $wpdb;
    $tagsToShow = $wpdb->get_results("\n    SELECT SUBSTR(option_name,11) as id\n    FROM wp_options\n    WHERE option_name LIKE 'filter_tag%' and option_value = 'on' and length(option_name) > 10");
    $tagLinks = array();
    foreach ($tagsToShow as $tag) {
        $name = get_tag($tag->id);
        $tagLinks['Alla nyheter'] = home_url('/nyheter');
        $tagLinks[$name->name] = get_tag_link($tag->id);
    }
    if (!is_home() || is_tag()) {
        ?>
    <nav class="sub-pages-nav" role="navigation">
      <ul class="nav sub-pages">
        <?php 
        foreach ($tagLinks as $key => $value) {
            echo '<li><a href="' . $value . '">' . $key . '</a></li>';
        }
        ?>
      </ul>
    </nav>
  <?php 
    }
}
开发者ID:ungarh,项目名称:ungarh-tema,代码行数:28,代码来源:theme.php

示例3: handleChange

 /**
  * Triggers on a change event and adds the relevant URL's to the ban list
  *
  * Function inspired by Varnish HTTP Purge
  * https://github.com/Ipstenu/varnish-http-purge/blob/master/plugin/varnish-http-purge.php#L277
  *
  * @param  [type] $postId [description]
  * @return [type]         [description]
  */
 protected function handleChange($postId)
 {
     // If this is a valid post we want to purge the post, the home page and any associated tags & cats
     // If not, purge everything on the site.
     $validPostStatus = array("publish", "trash");
     $thisPostStatus = get_post_status($postId);
     // If this is a revision, stop.
     if (get_permalink($postId) !== true && !in_array($thisPostStatus, $validPostStatus)) {
         return;
     } else {
         // array to collect all our URLs
         $listofurls = array();
         // Category purge based on Donnacha's work in WP Super Cache
         $categories = get_the_category($postId);
         if ($categories) {
             foreach ($categories as $cat) {
                 $this->invalidateUrl(get_category_link($cat->term_id));
             }
         }
         // Tag purge based on Donnacha's work in WP Super Cache
         $tags = get_the_tags($postId);
         if ($tags) {
             foreach ($tags as $tag) {
                 $this->invalidateUrl(get_tag_link($tag->term_id));
             }
         }
         // Author URL
         $this->invalidateUrl(get_author_posts_url(get_post_field('post_author', $postId)));
         $this->invalidateUrl(get_author_feed_link(get_post_field('post_author', $postId)));
         // Archives and their feeds
         $archiveurls = array();
         if (get_post_type_archive_link(get_post_type($postId)) == true) {
             $this->invalidateUrl(get_post_type_archive_link(get_post_type($postId)));
             $this->invalidateUrl(get_post_type_archive_feed_link(get_post_type($postId)));
         }
         // Post URL
         $this->invalidateUrl(get_permalink($postId));
         // Feeds
         $this->invalidateUrl(get_bloginfo_rss('rdf_url'));
         $this->invalidateUrl(get_bloginfo_rss('rss_url'));
         $this->invalidateUrl(get_bloginfo_rss('rss2_url'));
         $this->invalidateUrl(get_bloginfo_rss('atom_url'));
         $this->invalidateUrl(get_bloginfo_rss('comments_rss2_url'));
         $this->invalidateUrl(get_post_comments_feed_link($postId));
         // Home Page and (if used) posts page
         $this->invalidateUrl(home_url('/'));
         if (get_option('show_on_front') == 'page') {
             $this->invalidateUrl(get_permalink(get_option('page_for_posts')));
         }
     }
     // Filter to add or remove urls to the array of purged urls
     // @param array $purgeUrls the urls (paths) to be purged
     // @param int $postId the id of the new/edited post
     // $this->invalidateUrls = apply_filters( 'vhp_purge_urls', $this->invalidateUrls, $postId );
 }
开发者ID:Rareloop,项目名称:wp-varnish-invalidator,代码行数:64,代码来源:VarnishInvalidator.php

示例4: My_TagCloud

function My_TagCloud($params = array())
{
    extract(shortcode_atts(array('orderby' => 'name', 'order' => 'ASC', 'number' => '', 'wrapper' => '', 'sizeclass' => 'tagSize-', 'sizemin' => 1, 'sizemax' => 5), $params));
    // initialize
    $ret = '';
    $min = 9999999;
    $max = 0;
    // fetch all WordPress tags
    $tags = get_tags(array('orderby' => $orderby, 'order' => $order, 'number' => $number));
    // get minimum and maximum number tag counts
    foreach ($tags as $tag) {
        $min = min($min, $tag->count);
        $max = max($max, $tag->count);
    }
    // generate tag list
    foreach ($tags as $tag) {
        $url = get_tag_link($tag->term_id);
        if ($max > $min) {
            $class = $sizeclass . floor(($tag->count - $min) / ($max - $min) * ($sizemax - $sizemin) + $sizemin);
        } else {
            $class = $sizeclass;
        }
        $ret .= ($wrapper ? '<' . $wrapper . ' class="tagWrapper">' : '') . '<a href="' . $url . '" class="' . $class . ' link">' . $tag->name . '</a>' . ($wrapper ? '</' . $wrapper . '>' : '');
    }
    return str_replace(get_bloginfo('url'), '', $ret);
}
开发者ID:synergia,项目名称:mknm-synergia-theme,代码行数:26,代码来源:utils.php

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

示例6: list_tags

/**
 * List the tags of posts as links. 
 * 
 * Creates links to tag posts in a comma separated list. 
 * 
 * @param  [array] $posttags  The array of tags
 * @return [string]           String of tags.
 */
function list_tags($posttags)
{
    if (isset($posttags) && is_array($posttags)) {
        foreach ($posttags as $tag) {
            if ($tag === end($posttags)) {
                ?>
				<a href="<?php 
                echo esc_attr(get_tag_link($tag->term_id));
                ?>
"> <?php 
                echo esc_html($tag->name);
                ?>
</a>
				<?php 
            } else {
                ?>
				<a href="<?php 
                echo esc_attr(get_tag_link($tag->term_id));
                ?>
"> <?php 
                echo esc_html($tag->name);
                ?>
</a>
				<?php 
            }
        }
    }
}
开发者ID:jeffreysmattson,项目名称:l7-display-posts,代码行数:36,代码来源:functions.php

示例7: wpml_link_to_element

function wpml_link_to_element($element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echoit = true)
{
    if (!function_exists('icl_link_to_element')) {
        switch ($element_type) {
            case 'post':
            case 'page':
                $ret = '<a href="' . get_permalink($element_id) . '">';
                if ($anchor) {
                    $ret .= $anchor;
                } else {
                    $ret .= get_the_title($element_id);
                }
                $ret .= '<a>';
                break;
            case 'tag':
            case 'post_tag':
                $tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
                $ret = '<a href="' . get_tag_link($element_id) . '">' . $tag->name . '</a>';
            case 'category':
                $ret = '<a href="' . get_tag_link($element_id) . '">' . get_the_category_by_ID($element_id) . '</a>';
            default:
                $ret = '';
        }
        if ($echoit) {
            echo $ret;
        } else {
            return $ret;
        }
    } else {
        return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
    }
}
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:32,代码来源:wpml-integration.php

示例8: widget

 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_name', $instance['title']);
     $count = $instance['count'];
     $offset = $instance['offset'];
     echo $before_widget;
     echo $before_title . $title . $after_title;
     /**
     * <div class="side-hot">
     		<h2>热门话题</h2>
     		<div class="hot-qui">
     		<?php wp_tag_cloud('smallest=12&largest=18&unit=px&number=20&orderby=count&order=DESC');?>
     		</div>
     		</div>
     */
     echo '<div class="side-hot"><h2>热门话题</h2><div class="hot-qui">';
     $tags_list = get_tags('smallest=12&largest=18&unit=px&orderby=count&order=DESC&number=' . $count . '&offset=' . $offset);
     if ($tags_list) {
         foreach ($tags_list as $tag) {
             echo '<a href="' . get_tag_link($tag) . '">' . $tag->name . ' (' . $tag->count . ')</a>';
         }
     } else {
         echo '暂无标签!';
     }
     echo '</div></div>';
     echo $after_widget;
 }
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:28,代码来源:tags.php

示例9: _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

示例10: widget

    /**
     * Outputs the HTML for this widget.
     *
     * @param array  An array of standard parameters for widgets in this theme
     * @param array  An array of settings for this widget instance
     * @return void Echoes it's output
     **/
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
        $text = empty($instance['text']) ? ' ' : apply_filters('widget_title', $instance['text']);
        echo $before_widget;
        echo $before_title;
        echo $title;
        // Can set this with a widget option, or omit altogether
        echo $after_title;
        //
        // Widget display logic goes here
        //
        /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/
        /* Here We Go, BUild the Gate to prevent headache to find out which the Output*/
        /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/
        ?>
	<?php 
        $tags = get_tags();
        $html = '<div class="tags">';
        foreach ($tags as $tag) {
            $tag_link = get_tag_link($tag->term_id);
            $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>#";
            $html .= "{$tag->name}</a>";
        }
        $html .= '</div>';
        echo $html;
        ?>

    <?php 
        echo $after_widget;
    }
开发者ID:webtechfreaky,项目名称:vienna-content-focused-personal-blog-theme,代码行数:39,代码来源:tags.php

示例11: wpm_url

function wpm_url($item, $nourl)
{
    switch ($item->type) {
        case 'Home':
            $sof = get_option('show_on_front');
            $pfp = get_option('page_for_posts');
            if ($sof == 'page') {
                $url = $pfp ? get_page_link($pfp) : $nourl;
            } else {
                $url = get_bloginfo('url', 'display');
            }
            return $url;
        case 'FrontPage':
            return get_bloginfo('url', 'display');
        case 'Tag':
            return get_tag_link($item->selection);
        case 'Category':
            return get_category_link($item->selection);
        case 'Page':
            return get_page_link($item->selection);
        case 'Post':
            return get_permalink($item->selection);
        case 'External':
            return $item->selection;
        case 'PHP':
            $out = eval($item->selection);
            return is_array($out) ? $out[1] : $out;
    }
    return $nourl;
}
开发者ID:swena,项目名称:Online-Magazine-Website,代码行数:30,代码来源:wpm-db.php

示例12: core_header_tag_cloud

function core_header_tag_cloud($tags, $args = '')
{
    global $wp_rewrite;
    $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args);
    if (!$tags) {
        return;
    }
    $counts = $tag_links = array();
    foreach ((array) $tags as $tag) {
        $counts[$tag->name] = $tag->count;
        $tag_links[$tag->name] = get_tag_link($tag->term_id);
        if (is_wp_error($tag_links[$tag->name])) {
            return $tag_links[$tag->name];
        }
        $tag_ids[$tag->name] = $tag->term_id;
    }
    $min_count = min($counts);
    $spread = max($counts) - $min_count;
    if ($spread <= 0) {
        $spread = 1;
    }
    $font_spread = $largest - $smallest;
    if ($font_spread <= 0) {
        $font_spread = 1;
    }
    $font_step = $font_spread / $spread;
    // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
    if ('name' == $orderby) {
        uksort($counts, 'strnatcasecmp');
    } else {
        asort($counts);
    }
    if ('DESC' == $order) {
        $counts = array_reverse($counts, true);
    }
    $a = array();
    $rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
    foreach ($counts as $tag => $count) {
        $tag_id = $tag_ids[$tag];
        $tag_link = clean_url($tag_links[$tag]);
        $tag = str_replace(' ', '&nbsp;', wp_specialchars($tag));
        $a[] = "\t<option value='{$tag_link}'>{$tag} ({$count})</option>";
    }
    switch ($format) {
        case 'array':
            $return =& $a;
            break;
        case 'list':
            $return = "<ul class='wp-tag-cloud'>\n\t<li>";
            $return .= join("</li>\n\t<li>", $a);
            $return .= "</li>\n</ul>\n";
            break;
        default:
            $return = join("\n", $a);
            break;
    }
    return apply_filters('core_header_tag_cloud', $return, $tags, $args);
}
开发者ID:sjcockell,项目名称:fuzzierlogic.blog,代码行数:60,代码来源:functions.php

示例13: widget

 function widget($args, $instance)
 {
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => null));
     $title = esc_attr($instance['title']);
     if (is_singular('post') && has_tag()) {
         global $post;
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo apply_filters('widget_title', $title, $instance, $this->id_base);
             echo $after_title;
         }
         echo '<div class="tagcloud">';
         $tags = wp_get_post_tags($post->ID);
         foreach ($tags as $t => $tag) {
             echo '<a href="' . get_tag_link($tag->term_id) . '" title="' . $tag->count . ' topic">';
             echo $tag->name;
             echo '</a>';
         }
         echo '<div class="clear"></div>';
         echo '</div>';
         echo $after_widget;
     }
 }
开发者ID:bettirosengugi,项目名称:My-Web-Projects,代码行数:26,代码来源:my_wdg_post_tags.php

示例14: widget

 function widget($args, $instance)
 {
     global $post;
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => ''));
     $title = $instance['title'];
     if (is_singular('post') && has_tag()) {
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo apply_filters('widget_title', esc_attr($title), $instance, $this->id_base);
             echo $after_title;
         }
         echo '<div class="tagcloud">';
         $tags = wp_get_post_tags($post->ID);
         foreach ($tags as $t => $tag) {
             $tag_url = get_tag_link($tag->term_id);
             if (is_wp_error($tag_url)) {
                 continue;
             }
             echo '<a href="' . esc_url($tag_url) . '" title="' . absint($tag->count) . '">';
             echo esc_html($tag->name);
             echo '</a>';
         }
         echo '<div class="clearfix"></div>';
         echo '</div>';
         echo $after_widget;
     }
 }
开发者ID:AWD-Development,项目名称:tornado_zahid,代码行数:30,代码来源:mythemes.post_tags.class.php

示例15: widget

 function widget($args, $instance)
 {
     global $post;
     extract($args);
     $tagstitle = isset($instance['tagstitle']) ? esc_attr($instance['tagstitle']) : '';
     if ($tagstitle == "") {
         $tagstitle = __("Tags", "indonez");
     }
     echo $before_widget;
     echo $before_title . $tagstitle . $after_title;
     $tags = array();
     $posts = get_posts('numberposts=-1');
     foreach ($posts as $p) {
         foreach (wp_get_post_tags($p->ID) as $tag) {
             if (array_key_exists($tag->name, $tags)) {
                 $tags[$tag->name]['count']++;
             } else {
                 $tags[$tag->name]['count'] = 1;
                 $tags[$tag->name]['link'] = get_tag_link($tag->term_id);
             }
         }
     }
     // Show tag cloud
     echo '<div class="tag-cloud">';
     foreach ($tags as $tag_name => $tag) {
         echo '<a href="' . esc_url($tag['link']) . '">' . $tag_name . '</a>';
     }
     echo '</div>';
     echo $after_widget;
 }
开发者ID:kblizeck,项目名称:vall-technologies,代码行数:30,代码来源:theme-widgets.php


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