Integrations/WordPress
WordPress

Website screenshots in WordPress

Generate and display website thumbnails on your WordPress site

Integrate the Allscreenshots API with your WordPress site to automatically generate and display website screenshots. Perfect for link directories, resource pages, portfolio galleries, and affiliate sites that need visual previews of external URLs.

How it works

Connect in 4 steps

1

Get your API key

Sign up for Allscreenshots and grab your API key from the dashboard.

2

Add a custom function

Add a PHP function to your theme or a custom plugin to call the Allscreenshots API.

3

Display screenshots

Use a shortcode or block to display website screenshots in posts and pages.

4

Cache results

Use WordPress transients to cache screenshot URLs and avoid redundant API calls.

</> Code

WordPress Shortcode

php
1<?php
2// Add to functions.php or a custom plugin
3function allscreenshots_shortcode($atts) {
4    $atts = shortcode_atts([
5        'url' => '',
6        'width' => 1280,
7        'height' => 800,
8        'fullpage' => 'false',
9    ], $atts);
10
11    if (empty($atts['url'])) return '';
12
13    $cache_key = 'screenshot_' . md5($atts['url']);
14    $screenshot_url = get_transient($cache_key);
15
16    if (!$screenshot_url) {
17        $response = wp_remote_post(
18            'https://api.allscreenshots.com/v1/screenshot',
19            [
20                'headers' => [
21                    'Authorization' => 'Bearer ' . SCREENSHOT_API_KEY,
22                    'Content-Type'  => 'application/json',
23                ],
24                'body' => wp_json_encode([
25                    'url'      => $atts['url'],
26                    'fullPage' => $atts['fullpage'] === 'true',
27                    'viewport' => [
28                        'width'  => (int) $atts['width'],
29                        'height' => (int) $atts['height'],
30                    ],
31                ]),
32            ]
33        );
34
35        $body = json_decode(wp_remote_retrieve_body($response));
36        $screenshot_url = $body->screenshotUrl;
37        set_transient($cache_key, $screenshot_url, DAY_IN_SECONDS);
38    }
39
40    return sprintf(
41        '<img src="%s" alt="Screenshot of %s" loading="lazy" />',
42        esc_url($screenshot_url),
43        esc_attr($atts['url'])
44    );
45}
46add_shortcode('screenshot', 'allscreenshots_shortcode');
47// Usage: [screenshot url="https://example.com"]
Why Allscreenshots

Built for WordPress

Simple shortcode

Display screenshots anywhere with [screenshot url="..."]. No coding beyond the initial setup.

Built-in caching

WordPress transients cache screenshot URLs to minimize API calls and speed up page loads.

No plugin dependency

A lightweight function — no bloated plugin needed. Add it to your theme or a mu-plugin.

FAQ

Frequently asked questions

There is no dedicated plugin yet, but the shortcode example above can be added to your theme's functions.php in minutes. It's lightweight and has no external dependencies.

Ready to integrate with WordPress?

Start with 100 free screenshots every month. No credit card required.