Forums

[resolved] please help with Warning: implode() (5 posts)

  1. kramz
    Member
    Posted 2 years ago #

    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. 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
    my code on line 38 looks like this:
    $exclude = implode (",".$bnf_exc_cat);

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

    Any tips?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Well you need a comma, not a period, in that implode:
    $exclude = implode (",",$bnf_exc_cat);

    so don't know if you need this, but just in case:

    if ($bnf_exc_cat) {
    $exclude = implode (",",$bnf_exc_cat);
    }
  3. kramz
    Member
    Posted 2 years ago #

    Hey MichaelH, thanks for your quick reply.

    I don't know why I posted it with a period, I do have it with a comma.
    It looks just like your example and the warning still shows up.
    I've been trying to find what seems to be the problem and it looks like it shows up only when the options are empty. Every time I check a category it gets excluded with no problem from the header. But, as soon as I uncheck them the warning shows up.

    How can I fix this?

  4. kramz
    Member
    Posted 2 years ago #

    Anyone?

  5. kramz
    Member
    Posted 2 years ago #

    Finally solved it! 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’.

Topic Closed

This topic has been closed to new replies.

About this Topic