Skip to Content

post_type()

Show the post type metadata.

PHP July 20, 2017

Usage

PHP
nebula()->post_type($icon)

Parameters

$icon
(Optional) (Boolean) Whether to show the icon
Default: true

Request or provide clarification »

Demo


Using post_meta:
Using individual Nebula post meta functions with options:
Other Nebula meta functions:
  • Functions
  • No EXIF data found

Source File

Located in /libs/Functions.php on line 514.

No Hooks

This function does not have any filters or actions available. Request one?
PHP
    public function post_type($icon=true){
        if ( get_theme_mod('search_result_post_types', true) ){
            $post_icon_img = '<i class="fas fa-thumbtack"></i>';
            if ( $icon ){
                global $wp_post_types;
                $post_type = get_post_type();

                if ( $post_type === 'post' ){
                    $post_icon_img = '<i class="fas fa-fw fa-thumbtack"></i>';
                } elseif ( $post_type === 'page' ){
                    $post_icon_img = '<i class="fas fa-fw fa-file-alt"></i>';
                } else {
                    $post_icon = $wp_post_types[$post_type]->menu_icon;
                    if ( !empty($post_icon) ){
                        if ( strpos('dashicons-', $post_icon) >= 0 ){
                            $post_icon_img = '<i class="dashicons-before ' . $post_icon . '"></i>';
                        } else {
                            $post_icon_img = '<img src="' . $post_icon . '" style="width: 16px; height: 16px;" loading="lazy" />';
                        }
                    } else {
                        $post_icon_img = '<i class="fas fa-thumbtack"></i>';
                    }
                }
            }

            return '<span class="meta-item post-type">' . $post_icon_img . ucwords(get_post_type()) . '</span>';
        }
    }

Override

This function can not be short-circuited with an override filter. Request one?