317 posts
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 100 and 199 users
  • Sold between 50 000 and 100 000 dollars
+1 more
kramz says

Need help from some ninja WP Guru…

Under my theme options I made a checkbox list of all my categories so that users can check to exclude from the header menu. It seems to work fine. However, when I don’t have any of them checked I get this warning on every page: Warning: implode() [function.implode]: Invalid arguments passed in /home/kramz/public_html/blog/wp-content/themes/blognfolio/header.php on line 38

Warning: implode() [function.implode]: Invalid arguments passed in /home/kramz/public_html/blog/wp-content/themes/blognfolio/header.php on line 43

line 38
$exclude = implode (",".$bnf_exc_cat);
line 43
$excludep = implode (",".$bnf_exc_pages);

Any tips will be great. Thanks.

226 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Russian Federation
  • Sold between 1 000 and 5 000 dollars
chipree says
I think you need to have 2 parameters when using implode.. right now you have 1 parameter:
”,”.$bnf_exc_cat
Did you meen to do:
”,”,$bnf_exc_cat
? You placed a . instead of a , ? That might be the error :P
629 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • United States
VagrantRadio says

It’s gonna asplode! er, implode! RUN !

Sorry, couldn’t resist.

317 posts
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 100 and 199 users
  • Sold between 50 000 and 100 000 dollars
+1 more
kramz says

Thanks cy21, yes I meant to use a comma. The issue is that I receive a warning: implode() [function.implode]: but only when there has not been a selection made. Once a selection is made then everything works as should.

226 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Russian Federation
  • Sold between 1 000 and 5 000 dollars
chipree says
Thanks cy21, yes I meant to use a comma. The issue is that I receive a warning: implode() [function.implode]: but only when there has not been a selection made. Once a selection is made then everything works as should.

I’m not sure.. might be wrong on this.. but when a checkbox is not selected I think it returns a empty string.. so if you pass that empty string in a array might create a empty array and does not see the second variable as a valid argument or does not see it at all so it gives error…

Try to see what the $bnf_exc_cat variable has inside and if empty fill it with something or change the code.. put a if… you choose :P

122 posts
  • Bought between 50 and 99 items
  • Denmark
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
  • Sold between 1 000 and 5 000 dollars
jayjdk says

Does this work?


if ( $bnf_exc_cat ) 
  $exclude = implode (",".$bnf_exc_cat);

226 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Russian Federation
  • Sold between 1 000 and 5 000 dollars
chipree says
Does this work?

if ( $bnf_exc_cat ) 
  $exclude = implode (",".$bnf_exc_cat);

why is everybody putting a . instead of a , in implode between variables ? (lol)

317 posts
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 100 and 199 users
  • Sold between 50 000 and 100 000 dollars
+1 more
kramz says
This is what I have
if ( $bnf_exc_cat ) 
  $exclude = implode (",",$bnf_exc_cat);

Another thing is that when testing it locally there’s no warning at all. But, when uploading it to my hosting provider the warning comes out.

317 posts
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 100 and 199 users
  • Sold between 50 000 and 100 000 dollars
+1 more
kramz says
Fixed! :)
Now I can go to sleep! I was killing myself. In case you’re wondering this is what I did:
$categorias = $bnf_exc_cat;
    if ($categorias){
        $categorias_exc= implode(",",$categorias);
    } else {
        $categorias_exc="";
    }

I assume this was because it was attempting to implode ‘nothing’.

Cheers!

122 posts
  • Bought between 50 and 99 items
  • Denmark
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
  • Sold between 1 000 and 5 000 dollars
jayjdk says
Does this work?

if ( $bnf_exc_cat ) 
  $exclude = implode (",".$bnf_exc_cat);

why is everybody putting a . instead of a , in implode between variables ? (lol)

Just took the code from the first post ;-)

@ kramz, good you made it work!

by
by
by
by
by
by