本文整理汇总了PHP中has_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP has_tag函数的具体用法?PHP has_tag怎么用?PHP has_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_tag函数的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;
}
}
示例2: ultra_entry_footer
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function ultra_entry_footer()
{
if (is_single() && has_category() && siteorigin_setting('blog_post_cats')) {
echo '<span class="cat-links">' . get_the_category_list(__(', ', 'ultra')) . '</span>';
}
if (is_single() && has_tag() && siteorigin_setting('blog_post_tags')) {
echo '<span class="tags-links">' . get_the_tag_list('', __(', ', 'ultra')) . '</span>';
}
if (siteorigin_setting('blog_edit_link')) {
edit_post_link(__('Edit', 'ultra'), '<span class="edit-link">', '</span>');
}
}
示例3: 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;
}
}
示例4: 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;
}
}
示例5: slider
function slider($queried_posts)
{
global $post;
?>
<section class="l-clear js-flickity m-flickity" data-flickity-options='{ "cellAlign": "left", "contain": true, "prevNextButtons": false, "wrapAround": true, "autoPlay": true}'>
<?php
foreach ($queried_posts as $post) {
setup_postdata($post);
echo '<a class="gallery-cell m-prf ratio-4-3 overlay" href="' . get_the_permalink() . '" title="' . get_the_title() . '">';
if (function_exists('makeitSrcset') && has_post_thumbnail()) {
makeitSrcset(get_post_thumbnail_id($post->ID), 83, 62, 39, 34, 28);
}
echo '<h3 class="a-medium a-prf-text">' . get_the_title();
echo '<br/>';
echo '<span class="a-prf-text__span">';
echo get_the_time('Y-m-d');
if (has_tag()) {
echo strip_tags(get_the_tag_list(' · ', ' · ', ''));
}
echo '</span>';
echo '</h3>';
echo '</a>';
}
?>
</section>
<?php
wp_reset_postdata();
}
示例6: phg_gold_social_icons
/**
* Display social links in footer and widgets
*
* @package phg_gold
*/
function phg_gold_social_icons()
{
if (has_nav_menu('social-menu')) {
if (has_tag('location')) {
if (has_tag('bacara')) {
$_menu_name = "Bacara Social Menu";
} elseif (has_tag('balboa')) {
$_menu_name = "Balboa Social Menu";
} elseif (has_tag('estancia')) {
$_menu_name = "Estancia Social Menu";
} elseif (has_tag('koakea')) {
$_menu_name = "Koa Kea Social Menu";
} elseif (has_tag('meritage')) {
$_menu_name = "Meritage Social Menu";
} elseif (has_tag('pasea')) {
$_menu_name = "Pasea Social Menu";
} else {
$_menu_name = "Social Menu";
}
wp_nav_menu(array('theme_location' => 'social-menu', 'container' => 'nav', 'menu' => $_menu_name, 'container_id' => 'social', 'container_class' => 'social-icons', 'menu_id' => 'menu-social-items', 'menu_class' => 'social-menu', 'depth' => 1, 'fallback_cb' => '', 'link_before' => '<i class="social_icon fa"><span>', 'link_after' => '</span></i>'));
} else {
wp_nav_menu(array('theme_location' => 'social-menu', 'container' => 'nav', 'container_id' => 'social', 'container_class' => 'social-icons', 'menu_id' => 'menu-social-items', 'menu_class' => 'social-menu', 'depth' => 1, 'fallback_cb' => '', 'link_before' => '<i class="social_icon fa"><span>', 'link_after' => '</span></i>'));
}
}
}
示例7: rayaparvaz_hide_if_no_cats
/**
* Conditionally displays a field when used as a callback in the 'show_on_cb' field parameter
*
* @param CMB2_Field object $field Field object
*
* @return bool True if metabox should show
*/
function rayaparvaz_hide_if_no_cats($field)
{
// Don't show this field if not in the cats category
if (!has_tag('cats', $field->object_id)) {
return false;
}
return true;
}
示例8: greybox_tags
function greybox_tags()
{
$tags_array = has_tag();
if (!empty($tags_array)) {
printf(__('Tagged with: %s', 'greybox'), get_the_tag_list('', ', ', ''));
} else {
_e('This post has no tags.', 'greybox');
}
}
示例9: solostream_featureclass
function solostream_featureclass()
{
$featureclass = '';
global $post;
if (has_tag('full-image')) {
$featureclass = ' class="full-width"';
} else {
$featureclass = '';
}
return $featureclass;
}
示例10: phg_gold_partner_icons
/**
* Display partner links in footer and widgets
*
* @package phg_gold
*/
function phg_gold_partner_icons()
{
if (has_nav_menu('partner-menu')) {
if (has_tag('bacara')) {
$_menu_name = "Bacara Partners Menu";
} else {
$_menu_name = "Partners Menu";
}
wp_nav_menu(array('theme_location' => 'partner-menu', 'container' => 'nav', 'menu' => $_menu_name, 'container_id' => 'partner', 'container_class' => 'partner-icons', 'menu_id' => 'menu-partner-items', 'menu_class' => 'partner-menu', 'depth' => 1, 'fallback_cb' => '', 'link_before' => '<i class="partner_icon page-item-' . $ID . '"><span>', 'link_after' => '</span></i>'));
}
}
示例11: swp_yummly_button_html
function swp_yummly_button_html($array)
{
// If we've already generated this button, just use our existing html
if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['yummly'])) {
$array['resource']['yummly'] = $_GLOBALS['sw']['buttons'][$array['postID']]['yummly'];
// If not, let's check if Yummly is activated and create the button HTML
} elseif (isset($array['options']['newOrderOfIcons']['yummly']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['yummly'])) {
if (isset($array['options']['yummly_categories']) && $array['options']['yummly_categories'] != '' && in_category($array['options']['yummly_categories'], $array['postID']) || isset($array['options']['yummly_tags']) && $array['options']['yummly_tags'] != '' && has_tag($array['options']['yummly_tags'], $array['postID']) || (!isset($array['options']['yummly_tags']) && !isset($array['options']['yummly_categories']) || $array['options']['yummly_categories'] == '' && $array['options']['yummly_tags'] == '')) {
$array['totes'] += $array['shares']['yummly'];
++$array['count'];
// Let's create a title
if (get_post_meta($array['postID'], 'nc_ogTitle', true)) {
// If the user defined an social media title, let's use it.
$title = urlencode(urldecode(get_post_meta($array['postID'], 'nc_ogTitle', true)));
} else {
// Otherwise we'll use the default post title
$title = urlencode(urldecode(get_the_title()));
}
if (get_post_meta($array['postID'], 'swp_open_graph_image_url')) {
$image = urlencode(urldecode(get_post_meta($array['postID'], 'swp_open_graph_image_url', true)));
} else {
$image = urlencode(urldecode(get_post_meta($array['postID'], 'swp_open_thumbnail_url', true)));
}
$array['resource']['yummly'] = '<div class="nc_tweetContainer swp_yummly" data-id="' . $array['count'] . '" data-network="yummly">';
// $link = urlencode(urldecode(swp_process_url( $array['url'] , 'yummly' , $array['postID'] )));
$link = $array['url'];
$array['resource']['yummly'] .= '<a target="_blank" href="http://www.yummly.com/urb/verify?url=' . $link . '&title=' . $title . '&image=' . $image . '&yumtype=button" data-link="http://www.yummly.com/urb/verify?url=' . $link . '&title=' . $title . '&image=' . $image . '&yumtype=button" class="nc_tweet">';
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['yummly'] > 0) {
$array['resource']['yummly'] .= '<span class="iconFiller">';
$array['resource']['yummly'] .= '<span class="spaceManWilly">';
$array['resource']['yummly'] .= '<i class="sw sw-yummly"></i>';
$array['resource']['yummly'] .= '<span class="swp_share"> ' . __('Yum', 'social-warfare') . '</span>';
$array['resource']['yummly'] .= '</span></span>';
$array['resource']['yummly'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['yummly']) . '</span>';
} else {
$array['resource']['yummly'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-yummly"></i><span class="swp_share"> ' . __('Yum', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['yummly'] .= '</a>';
$array['resource']['yummly'] .= '</div>';
// Store these buttons so that we don't have to generate them for each set
$_GLOBALS['sw']['buttons'][$array['postID']]['yummly'] = $array['resource']['yummly'];
}
}
return $array;
}
示例12: get_related_posts
public function get_related_posts($args)
{
global $post;
$this->_post = $post;
$args['ignore_sticky_posts'] = 1;
$args['post__not_in'] = array($this->_post->ID);
if ($args['method'] == 'tag') {
if (has_tag()) {
return $this->search_by_tag($args, $this->_post->ID);
}
} elseif ($args['method'] == 'category') {
return $this->search_by_category($args);
} else {
$search_term = get_the_title();
$args['s'] = $search_term;
$q = new WP_Query($args);
if (count($q->posts) < $args['posts_per_page']) {
$search_terms = explode(' ', $search_term);
foreach ($search_terms as $search_term) {
$args['s'] = $search_term;
$r = new WP_Query($args);
if (count($r->posts) > 0) {
$q->posts = array_merge($q->posts, $r->posts);
}
if (count($q->posts) > $args['posts_per_page']) {
$c = count($q->posts);
for ($i = $args['posts_per_page']; $i <= $c; $i++) {
unset($q->posts[$i]);
}
break;
}
}
}
if (count($q->posts) < 1) {
if (has_tag()) {
return $this->search_by_tag($args, $this->_post->ID);
} else {
return $this->search_by_category($args);
}
}
return apply_filters('pf_related_posts_result', $q, $args);
}
}
示例13: tagifyConvertedMoney
/**
* pass-1: let converters to find money notations and add short codes
*
* @Filter(tag="the_content")
*/
public function tagifyConvertedMoney($text)
{
if (has_tag('acc_disable')) {
return $text;
}
// if the post was modified before the begin date set by plugin, pass.
$options = get_option(self::DB_OPTION_KEY);
if (is_array($options) && array_key_exists('begin_date', $options)) {
$begin_date = $options['begin_date'];
$modified_date = get_the_modified_date('Y-m-d');
// we can asssume that the both date format are the same in Y-m-d
if ($begin_date > $modified_date) {
return $text;
}
}
foreach ($this->_taggers as $tagger) {
$text = $tagger->apply($text);
}
return $text;
}
示例14: meta_elements
/**
* Figure out the post meta that we want to use and inject them to our content.
*/
public static function meta_elements($post_id = '')
{
if ('' == $post_id) {
global $post;
$post_id = $post->ID;
}
$post = get_post($post_id);
// Get the options from the db
$metas = get_theme_mod('maera_entry_meta_config', 'post-format, date, author, comments');
$date_format = get_theme_mod('date_meta_format', 1);
$categories_list = has_category('', $post_id) ? get_the_category_list(__(', ', 'maera_bs'), '', $post_id) : false;
$tag_list = has_tag('', $post_id) ? get_the_tag_list('', __(', ', 'maera_bs')) : false;
// No need to proceed if the option is empty
if (empty($metas)) {
return;
}
$content = '';
// convert options from CSV to array
$metas_array = explode(',', $metas);
// clean up the array a bit... make sure there are no spaces that may mess things up
$metas_array = array_map('trim', $metas_array);
return $metas_array;
}
示例15: restful_post_meta_below
/**
* Post meta for below the post.
*/
function restful_post_meta_below()
{
if (!has_category() && !has_tag()) {
return false;
}
?>
<div class="entry__meta entry__meta--inline entry__meta--below">
<?php
if (has_category()) {
?>
<div class="entry__meta-item">
<i class="fa fa-folder"></i>
<?php
the_category(', ');
?>
</div>
<?php
}
?>
<?php
if (has_tag()) {
?>
<div class="entry__meta-item">
<i class="fa fa-tags"></i>
<?php
the_tags('');
?>
</div>
<?php
}
?>
</div>
<?php
}