Using WordPress ‘get_last_updated()’ PHP function

The get_last_updated() WordPress PHP function retrieves a list of the most recently updated blogs.

Usage

Here’s a generic example of how to use the function:

$recent_blogs = get_last_updated($deprecated, $start, $quantity);

For instance, to get the 10 most recently updated blogs, skipping the first 5:

$recent_blogs = get_last_updated('', 5, 10);

Parameters

  • $deprecated (mixed) – Optional. Not used. Default: ''
  • $start (int) – Optional. Number of blogs to offset the query. Used to build the LIMIT clause. Can be used for pagination. Default: 0
  • $quantity (int) – Optional. The maximum number of blogs to retrieve. Default: 40

More information

See WordPress Developer Resources: get_last_updated

Examples

Retrieve the 5 most recently updated blogs

This example retrieves the 5 most recently updated blogs.

$recent_blogs = get_last_updated('', 0, 5);

Retrieve the 10 most recently updated blogs

This example retrieves the 10 most recently updated blogs.

$recent_blogs = get_last_updated('', 0, 10);

Retrieve the most recently updated blog

This example retrieves the most recently updated blog.

$recent_blogs = get_last_updated('', 0, 1);

Pagination: Retrieve blogs 11-20

This example retrieves blogs 11-20 in the list of most recently updated blogs.

$recent_blogs = get_last_updated('', 10, 10);

Pagination: Retrieve blogs 21-30

This example retrieves blogs 21-30 in the list of most recently updated blogs.

$recent_blogs = get_last_updated('', 20, 10);

Tagged in

Leave a Comment

Your email address will not be published. Required fields are marked *