how to get the proper post id on a static page with a post on it (2 posts)

  1. vasilescu_anton
    Posted 6 years ago #

    Hi everybody,

    I've been struggling for couple hours now to get the post id of a static page on which i've added the loop to display some posts in a certain category. I know that the page id for the static page is 18 while the id of the first post displayed on the page is 165.

    Now, when I use the_ID() I get 165 or if I try is_page('18') it returns false! Why is it returning the id of the first post instead of the parent page?

    Any idea what am I doing wrong here?

  2. vasilescu_anton
    Posted 6 years ago #

    Ok, so to make this even more clear, I have the_ID() and is_page() in the sidebar.php and I need it evaluated in the main page that calls it. Does this make a difference? Also the sidebar.php has it's own loop that builds a list of the 3 posts that are displayed on the main page.

Topic Closed

This topic has been closed to new replies.

About this Topic