0

How do widgets embedded in a page access posts they should display?

How do widgets (php code) in the page access the posts they should display (via the used template's post loop / with wp_query and get_posts() / both possible)?

1

How do widgets embedded in a page access posts they should display?

That's not how widgets work, and implies there is a framework that provides posts to widgets. There is not. Widgets aren't embedded either, and there is no data source that provides what they should display. Widgets decide that on their own.

So if a widget displays the latest posts, it does this because it was programmed to do that, not because it was provided the latest posts to display. Widgets don't follow the standard main post loop system where WordPress fetched posts. A widget is an arbitrary piece of code with output, that fits into a WP_Widget class.

For example, a widget with a paginated list of posts would implement that pagination internally from scratch.

To get an answer for this, you will need to read the code that implements the specific widget you are interested in, as no generic framework exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.