Because We Love Happy Coding

フリーライターからエンジニア × 講師。発信力だけあり余ってる感じ

Solution to Warnings of Pitch_Walker_Page in wordpress theme "pitch"

今日もまたコーディング。だって僕らはHappy Codingが大好きだから。

I was looking for a wordpress theme that's go well with custom post types. Only a few choice I could find... and this "pitch" looks good to me.

wordpress.org

But when I activated it, I found a Warning.

Warning: Declaration of Pitch_Walker_Page::start_el(&$output, $page, $depth, $args, $current_page = 0) should be compatible with Walker_Page::start_el(&$output, $page, $depth = 0, $args = Array, $current_page = 0) in /home/[blog_name]/public_html/wp-content/themes/pitch/functions.php on line 435

I googled it.

Official Forum

Official Forum ends up with "Thread resolved via alternative support channel". Mmm...

This means at least I am not the only one who met this warning. This happens in some conditions.

wordpress.stackexchange.co

Another hint here.

wordpress.stackexchange.com

The Answer by JHoffmann suggests this is error comes from extension. In the programming, child class extends from parent class, and child's signature should be the same with parent's. Signature here means parameter list, i.e. keywords in parensis. JHoffmann suggests to copy the parent's signature to child's. OK, I will try.

try

Open functions.php in theme/pitch/ directory and see line 446.

function start_el(&$output, $page, $depth, $args, $current_page = 0) 

Change this line to the following.

function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {

This worked perfectly for me.

The cause

I don't know what was wrong but maybe version-up to PHP7 caused this. PHP7 returns different values from PHP5.

参考URL

siteorigin.com