Skip to Content
Menu

the_author()

Determine if the author should be the company name or specific author’s name.

PHP March 16, 2017

Usage

PHP
nebula()->the_author($show_authors)

Parameters

$show_authors
(Optional) (Boolean) Force the author names to show
Default: true

Request or provide clarification »

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

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

    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
    "pre_nebula_the_author"
    Need a new filter hook? Request one here.

    Actions
    This function has no action hooks available. Request one?

    Note: This function contains 1 to-do comment.

    PHP
            public function the_author($show_authors=1){
                $override = apply_filters('pre_nebula_the_author', null, $show_authors);
                if ( isset($override) ){return $override;}
    
                if ( !is_single() || $show_authors === 0 || !$this->get_option('author_bios') ){
                    return $this->get_option('site_owner', get_bloginfo('name'));
                } else {
                    //@TODO "Nebula" 0: Add support for multi-authors? is_multi_author()
                    return ( get_the_author_meta('first_name') != '' )? get_the_author_meta('first_name') . ' ' . get_the_author_meta('last_name') : get_the_author_meta('display_name');
                }
            }
    

    Override

    To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):

    PHP
    add_filter('pre_nebula_the_author', 'my_custom_the_author', 10, 2); //The last integer must be 1 more than the actual parameters
    function my_custom_the_author($null, $show_authors){ //$null is required, but can be ignored
        //Write your own code here
    
        return true; //Return true to prevent the original function from running afterwords
    }

    You can completely disable this PHP function with a single line actions:

    PHP
     add_filter('pre_nebula_the_author', '__return_false');