WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can I limit a Plugin Widget in a sidebar to certain pages only? (4 posts)

  1. somanyqs
    Member
    Posted 5 years ago #

    warning... *very* new WP user here...

    I am making my way around WP, themes and plugins (don't know how to code but I'm not afraid to cut things up and see what changes to learn!).

    I am wondering if it is possible to limit a plugin in a sidebar (in this case I am thinking of WP-Polls, which I really like) to only show up when a user is on a specific page.

    I would like the Plugin Widget (I don't know if that is even the right terminology!) to appear in the left sidebar, which I can do using the Design>Widgets admin section and then "Current Widgets". So I can easily put the widget into Sidebar 1 (I am using the Whitespace theme), but it will then appear on every page of my site. I guess since the same sidebar appears no matter what page the user is on?

    I do like the sidebar and the rest of the stuff in it, and I want that to show up to matter what page the user goes to. But I would like the WP-Poll to only appear on the home page, then when the user goes to any other page the WP-Poll simply disappears. Is that even possible? I don't know if this is a plugin or theme question, really.

    Oh - and if I'm completely in the wrong forum, just give me a shout. Til then, I'm going to keep searching forums to figure out if I can find the answer.

    Thank you so much
    Regards,
    Jon

  2. alanft
    Member
    Posted 5 years ago #

  3. Michael Torbert
    WordPress Virtuoso
    Posted 5 years ago #

    This will execute the code for page 5:

    if ($post->ID == 5){
    code for page 5
    }

    This will execute the code on everything but page 5:

    if ($post->ID != 5){
    code for everything other than page 5
    }

    This will execute the code on page 5 and page 6:

    if ($post->ID == 5 || $post->ID == 6){
    code for page 5 and 6
    }

  4. somanyqs
    Member
    Posted 5 years ago #

    Fantastic - thank you both so much!!
    J

Topic Closed

This topic has been closed to new replies.

About this Topic