Usage
PHP
nebula()->post_tags($icon)
Parameters
$options
(Optional) (Array) An array of options
Default: None
Parameter Notes
id
The post ID to get tags for
Default: current post
label
Whether to show the tag “icon”, “text”, or not
Default: icon
force
Override the Customizer setting
Default: false
string
Return a string with no markup
Default: false
Demo
Using post_meta
:
Using individual Nebula post meta functions with options:
Other Nebula meta functions:
Source File
Located in /libs/Functions.php on line 645.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"nebula_post_tags_defaults"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?
PHP
public function post_tags($options=array()){ $defaults = apply_filters('nebula_post_tags_defaults', array( 'id' => get_the_ID(), 'label' => 'icon', //"icon" or "text" 'linked' => true, //Link to tag archive 'force' => false, 'string' => false, //Return a string with no markup )); $data = array_merge($defaults, $options); if ( get_theme_mod('post_tags', true) || $data['force'] ){ $tag_list = get_the_tag_list('', ', ', '', $data['id']); if ( $tag_list ){ $label = ''; if ( $data['label'] === 'icon' ){ $the_tags = get_the_tags(); $tag_plural = ( !empty($the_tags) && is_array($the_tags) && count($the_tags) > 1 )? __('tags', 'nebula') : __('tag', 'nebula'); //One time get_the_tags() was not an array and caused a PHP error, so this conditional is for extra precaution $label = '<i class="nebula-post-tags-label fa-solid fa-fw fa-' . $tag_plural . '"></i> '; } elseif ( $data['label'] === 'text' ){ $label = '<span class="nebula-post-tags-label">' . ucwords($tag_plural) . ' </span>'; } if ( !$data['linked'] ){ $tag_list = strip_tags($tag_list); } if ( $data['string'] ){ return strip_tags($tag_list); } return '<span class="posted-in meta-item post-tags">' . $label . $tag_list . '</span>'; } } }
Override
This function can not be short-circuited with an override filter. Request one?