WordPress.org

Ready to get started?Download WordPress

Forums

Featured Post Widget
Excluding featured post from another loop (4 posts)

  1. robertocarroll
    Member
    Posted 1 year ago #

    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/

  2. tepelstreel
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. robertocarroll
    Member
    Posted 1 year ago #

    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

  4. tepelstreel
    Member
    Plugin Author

    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.