WordPress.org

Support

Support » Plugins and Hacks » Featured Post Widget » Excluding featured post from another loop

Excluding featured post from another loop

  • Hello,

    I’m using your plugin to show a featured post at the top of a page. It’s great, thanks!

    I need to exclude the post chosen in your widget from another loop below.

    I tried getting the post id using get_the_ID in your plugin page and I can echo to ID, but I can’t seem to retrieve it on the actual page where the widget is …

    I need the ID so I can use it in post__not_in in my other loop.

    Any ideas how best to approach this?

    Thanks in advance for your help.

    best,
    Rob

    http://wordpress.org/extend/plugins/post-feature-widget/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author tepelstreel

    @tepelstreel

    Hello Rob,

    that’s quiet a wish that you have 🙂

    The problem is the structure of WP with sidebars and different loops. A widget is an instance of a given class as a child of another class. So, of course you can get the ID and echo it inside the instance of the widget that is displayed on your side.

    The problem is, that that doesn’t help you very much, because that ID will always stay in the child class of the Wp widget class. What you could do is taking the $instance['id'] and $instance['bid'] in the file FP_WidgetClass.php and make the global in order to retrieve them in another loop (that has to be fired after the loop of the widget has fired).

    That would be the quickest solution, I could think of, but I don’t have the time right now to test it out.

    Another possibilty is, to build in a hook to the widget to that would return the ID of the currently displayed post.

    Best,
    Stefan

    Hello Stefan,

    Thanks so much for responding and for your helpful suggestions. I did try making a global variable and passing the ID to it, but I couldn’t get it to work. I’ll give your ideas a go and will post here when I’ve had chance to experiment.

    Thanks again for your help.

    best,
    Rob

    Plugin Author tepelstreel

    @tepelstreel

    Hello Rob,

    I will test as well at one point. Sounds like an interesting task. But I won’t have time before next month, I guess.

    Best,
    Stefan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluding featured post from another loop’ is closed to new replies.
Skip to toolbar