WordPress.org

Ready to get started?Download WordPress

Forums

Using IF with OR (7 posts)

  1. Colin Young
    Member
    Posted 9 months ago #

    I want to do the following:
    ###########################################
    if is_page page1 or page2 or page3 or page4

    use this CSS

    else

    use other css
    ###########################################

    I know I could probably use lots of elseif statements but I wanted a more efficient way to to it.

    Can anyone help please?

  2. Andrew
    Forum Moderator
    Posted 9 months ago #

    Check if your pages are using a common template, then check if your '<body>' tag in the outputted HTML of those pages has that template name in a class. If they do then use the class.

  3. Colin Young
    Member
    Posted 9 months ago #

    oh, I think I might not be ready for that :)

    I have already managed to get my header to do

    if this page
    use this CSS
    else
    use other CSS

    I am kind of new to this stuff so not sure what you mean.

    Think I might have flooked the bit I've got working :)

  4. Andrew
    Forum Moderator
    Posted 9 months ago #

    Which theme are you using?

  5. Colin Young
    Member
    Posted 9 months ago #

    Its a custom one.

    Transferring an HTML page over to wordpress to give someone a CMS to work with. The original page was written by someone else but the majority of the css was already written.

    I can't publish the page just now because the person I am doing it for may have a problem with his current web dev and is going to move away from him.

    If I can give you some detail about it then I will give you what I can. Most of the site is working apart from a few positional problems

  6. martcol
    Member
    Posted 9 months ago #

    Maybe you need to read up a bit on CSS selectors?

    CSS will apply rules based on selectors combining element, class and/or I'd as well as some other things.

    It's a bit like IF this element has this class and is nested in this element apply this rule...

    And so on

  7. Colin Young
    Member
    Posted 9 months ago #

    I will have a read at them. My knowledge is limited so I am picking things up as I go along.

    In saying that, I have it working using if elseif else. I just wanted to see if I could make it more efficient.

    The situation is a bunch of christmas pages. The good thing is they won't be used again until next year. My concern is if the guy who owns the site wants events for multiple things through the year and I end up with pages of elseif statements :)

Reply

You must log in to post.

About this Topic

Tags

No tags yet.