WordPress.org

Ready to get started?Download WordPress

Forums

Test if you are on a permalink page (6 posts)

  1. GabrielRadic
    Member
    Posted 9 years ago #

    Hello all,
    I am trying to tweak the layout of my home page. Is there a way to test if the current page is a permalink page, an archive or the home page?
    I tried everything and I've searched the forum for half a day. There must be something obvious that I am missing.
    Please help. TIA.

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    Look at the address bar.
    An archive is a permalinked page, and a permalinked page will look like an archive, if that makes sense.

  3. GabrielRadic
    Member
    Posted 9 years ago #

    Ugh... sorry about that.
    What I mean is: What kind of PHP test should I perform inside index.php in order to have different output for the permalink pages and the home/other pages.
    Something like
    if ($justArticle) {
    /* do article stuff */
    } else {
    /* do homepage or archive */
    }

  4. codergurl
    Member
    Posted 9 years ago #

    <?php
    if ($single) {
    /* blah blah blah */
    } else {
    /* blah blah blah */
    }
    ?>

    In 1.3-alpha, you can use is_single() instead of $single.

  5. TechGnome
    Moderator
    Posted 9 years ago #

    You'll have to forgive podz, he's a little dense sometimes. ;P
    TG

  6. GabrielRadic
    Member
    Posted 9 years ago #

    It worked, thanks codegurl! I knew it should be this easy :-)
    NB: feeds for each topic is gold.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.