WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] The post id is not working (7 posts)

  1. little_kostas
    Member
    Posted 1 year ago #

    Hello i have the following code which i want, when the page id=102 to not show the sidebar.

    <?php
    $page_id = get_the_ID();
    if(!$page_id == 102) { do_action('sidebar_left'); }
    ?>

    The problem is that the sidebar is hidden from all the pages. What is the problem with that code?

    Thanks

  2. tomontoast
    Member
    Posted 1 year ago #

  3. little_kostas
    Member
    Posted 1 year ago #

    How will i exclude 102 page from showing the sidebar?

  4. tomontoast
    Member
    Posted 1 year ago #

    Like so

    <?php
    $page_id = get_the_ID();
    if(!$page_id == 102) { get_the_sidebar(); }
    ?>
  5. little_kostas
    Member
    Posted 1 year ago #

    For some strange reason the
    if(!$page_id == 102)
    is not working.
    Why is that???

    I had to use the
    if(!(page_id==102)) which works fine...

  6. tomontoast
    Member
    Posted 1 year ago #

    Woops it should of course be either if(!(page_id==102)) or if(page_id!=102)

    I should have spotted that!

  7. little_kostas
    Member
    Posted 1 year ago #

    Everything works fine.

Topic Closed

This topic has been closed to new replies.

About this Topic