The MU forums have moved to WordPress.org

Blog ID (8 posts)

  1. peiqinglong
    Member
    Posted 15 years ago #

    For the life of me, I can't find the answer to this. I've seen it on the forum one time, but I can't find it doing numerous searches.

    What I'm trying to do is create a dynamic highlighting menu for blogs. I can't figure out the code or string so that:

    <li <?php if (blog_id=3) { echo " id=\"current\""; } ?>>

    Does anyone remember the function that displays the blog-id? Thanks!

  2. drmiketemp
    Member
    Posted 15 years ago #

    You forgot the dollar sign. It's $blog_id.

    Hope this helps,
    -drmike

  3. peiqinglong
    Member
    Posted 15 years ago #

    Dr.Mike,

    That does put me in the right direction, but I'm still stuck. I found in another thread to use <?php global $blog_id; echo $blog_id; ?>, which will echo me the blog_id (good), but I'm having problems completing the second part of the string to say that if it outputs a certain number to apply id=current to it.

  4. drmiketemp
    Member
    Posted 15 years ago #

    Have you changed if statement to ($blog_id=3) though?

  5. rickybrennanjr
    Member
    Posted 15 years ago #

    also be careful, = should be == in an if statement , otherwise you're setting the variable ;-)

  6. peiqinglong
    Member
    Posted 15 years ago #

    Well this is what I got:

    <li<?php if ($blog_id==2) { echo " id=\"current\""; } ?>>

    It still doesn't display the id="current" when I'm on blog #2.

  7. peiqinglong
    Member
    Posted 15 years ago #

    Got it, I'm an idiot, the correct code should be:

    <li<?php global $blog_id; if ($blog_id==2) { echo " id=\"current\""; } else { }; ?>>

    Thanks all!

  8. pschena
    Member
    Posted 14 years ago #

    peiqinglong, thanks for posting the final working code.
    I needed the exact same functionality, worked perfectly!
    Cheers.

About this Topic

  • Started 15 years ago by peiqinglong
  • Latest reply from pschena