• I am using the following function that I coded (I am VERY new to this) to take the catgory page that someone is looking at to set a variable that I would like to use in my sidebar.

    <?php
    function myfunc(){
    	global $myVar;
    	if (is_category(16)) {
    			$myVar = 16;
    	}
    	return $myVar;
    }
    ?>

    The only problem is that I think im using the code wrong in the sidebar.php

    <?php
    if (is_home()) {
            echo "<ul>";  wp_list_cats('optionall=0&sort_column=name&list=1&children=0');
            echo "</ul>";
    } elseif (is_single() && $myCtg == "16") {
    		echo "<ul>";	wp_list_bookmarks('category_before=<span>&category_after=</span>&categorize=1&category=16&show_images=0&show_description=0&orderby=url');
    		echo "</ul>";
    }
    ?>

    because I also have an else set up to catch anything that doesnt work, and that is what keeps showing up in my sidebar.

    Any ideas on how I could make this work, or am I going about this in an entirely wrong way?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Well for one thing when you declared the variable it was myVar then in your sidebar your using $myCtg.

    Also instead of troubleshooting code why not describe what you’re trying to do, there is probably a much simpler way.

    Thread Starter armstrong1118

    (@armstrong1118)

    sorry, I was just trying to generalize everything for the post and missed the second halfI guess, all the variables are set to $myCtg

    Thread Starter armstrong1118

    (@armstrong1118)

    Update – I know for a fact that the function works ok, the problem is in the sidebar, for some reason how I address the variable in the if statement isnt catching.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin / Navigation help’ is closed to new replies.