Jason Han
Jason Han

Reputation: 33

PHP Warning: Missing argument 1

I'm pretty new to web designing and very eager to learn! I am currently working on a wordpress theme I've purchased and found the error log in the FTP server and was wondering if this is something I should be worried about or not?

It says

"[09-Sep-2014 01:58:36] PHP Warning: Missing argument 1 for kage_get_list_services(), called in /home2/neteffec/public_html/temp/wp-content/themes/kage-pro/template-homepage.php on line 21 and defined in /home2/neteffec/public_html/temp/wp-content/themes/kage-pro/functions.php on line 428"

Please let me know if you need more information! Thanks!

-Jason

Upvotes: 1

Views: 3320

Answers (1)

Don Rhummy
Don Rhummy

Reputation: 25820

That error message means that you did not pass in the required argument $n to the function kage_get_list_services. That's because your code is:

$services_testimonials = kage_get_list_services();

It should be:

//Pass whatever $n is supposed to be
$services_testimonials = kage_get_list_services( 13 );

The difference between required and non required arguments is if they have a default value. For example, you could change the function to be:

if ( ! function_exists( 'kage_get_list_services' ) )
{

    function kage_get_list_services($n = 10)
    { 
        global $wp_query;
        $args = array( 'post_type' => 'service', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => $n ); 
        $wp_query->query( $args ); 
        return new WP_Query( $args );
    }
}

In the above example, if you pass nothing, $n would be 10.

Upvotes: 0

Related Questions