Forums

[resolved] "if" statement is messing my page.php somehow? (5 posts)

  1. hilj
    Member
    Posted 4 years ago #

    I'm trying to show news in a sidebar on homepage.

    (the whole thing is in pastebin.)

    As soon as I ad this... (on line 11)

    <?php if (is_page('4'))
    		{
    		get_sidebar();
    		} ?>

    ...to get the sidebar, then the page content is not showing at all. I have two posts in the sidebar and they show where the Page content should be. The sidebar if fine though, but where's the Page content?

    The first "if" on line 3 has no effect to this, I tried to remove it and same happens.

    Hope someone can help, thank you so much!

  2. moshu
    Member
    Posted 4 years ago #

    I have two posts in the sidebar

    That's the problem: the Loop used in your sidebar over-writes the original Loop in the Page template.
    Read the Codex about the use of multiple Loops

  3. hilj
    Member
    Posted 4 years ago #

    I just added... `<?php query_posts(); ?> ...before the loop in page.php and it works. Is that proper way to it?

    This was very nice, thank you for you help!

  4. hilj
    Member
    Posted 4 years ago #

    Hmm... Now the page 4 content displays on every page. Didn't work. Any ideas?

    Thanks!

  5. moshu
    Member
    Posted 4 years ago #

    Read that article again. No, you didn't do it in the proper way.

Topic Closed

This topic has been closed to new replies.

About this Topic