• Hi

    I have wrote this piece of code so if the current page is category id 3 (my news category) then my news sub menu will appear.

    It may be wrong but it works.
    if ($cat = array(3) ) {
    $cat = array(3);

    What i want to do is apply the same rule for more categories. I need my portfolio, about and faq categories individuals menu’s to appear (id’s = 11,12,14) but i dont know how to add more to my code.

    Can anyone help?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Have a look at the Category conditional tags

    Eg:

    <?php if( is_category('3') ) get_sidebar('news');
    elseif( is_category('7') ) get_sidebar('services');
    else get_sidebar();?>

    For clarification, when you do this..

    if ($cat = array(3) ) {

    You’re basically saying if $cat can equal to array(3) (which it can), then do.. (whatever follows)..

    That statement will always be true.. $cat will always be set to an array with the value of 3 ..

    At least i believe that to be the case (based on my understanding).

    Esmi’s suggestion above should set you in the right direction though.. ??

    Thread Starter paulwallas

    (@paulwallas)

    thanks t31os_ it makes it a bit more clearer for me.

    I have looked at esmi’s link and half works, however i am not displaying a side bar.

    My site is set up with Home, About, News being categories and ‘education, experience, skills’ are all posts that display in the ‘about’ category.

    Therefore if the page is currently the about us cat(id3) i want the posts within this category to show ??

    How is this different from using standard category pages?

    Thread Starter paulwallas

    (@paulwallas)

    Sorry i am not too sure what you mean?

    Sorry – I was confused by your description of the situation. So is it that you want to show posts from 3 categories on the About category page? Or do you want to show different sub-menus on different category pages?

    Thread Starter paulwallas

    (@paulwallas)

    Hi

    I want to show different sub menu’s on different category pages.

    You can see the site here

    To get the code I posted above to work, you need to have already created your custom sidebars – sidebar-news.php and sidebar-services.php in the example.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Help with PHP code’ is closed to new replies.