โ† Back to Connections

Connect WordPress to PostPenguin

Easy SetupLanguage: PHPTime: 5 minutes

WordPress sites can receive PostPenguin posts automatically using our official plugin. Posts are published directly to your WordPress site with full SEO metadata.

Official WordPress Plugin Available!

We have an official WordPress plugin that handles everything automatically. No coding required - just install, configure your secret key, and you're ready to receive posts.

Download PluginVersion 1.0.0

๐Ÿš€ Quick Setup with Official Plugin

Step 1: Install the Plugin

  1. 1Download postpenguin.php from the plugin repository
  2. 2Upload to your WordPress wp-content/plugins/ directory
  3. 3Go to Plugins in WordPress admin and click Activate

Step 2: Configure the Plugin

  1. 1Go to Settings โ†’ PostPenguin in your WordPress admin
  2. 2Enter your Secret Key (this must match your PostPenguin site settings)
  3. 3Click Save Changes
  4. 4Copy the Webhook URL shown on the settings page

Step 3: Add to PostPenguin

  1. 1In PostPenguin, go to Dashboard โ†’ Add Site
  2. 2Enter your WordPress site URL
  3. 3Paste the webhook URL from the plugin settings page
  4. 4Enter the same secret key you configured in WordPress
That's it! Posts will now be automatically published to your WordPress site.

๐Ÿ“‹ What the Plugin Does

โœ… Automatic Publishing

Posts are published immediately when approved in PostPenguin

โœ… Signature Verification

HMAC-SHA256 verification ensures requests come from PostPenguin

โœ… Tag Support

Tags from PostPenguin are automatically added to WordPress posts

โœ… Update Detection

Existing posts are updated instead of creating duplicates

โš™๏ธ Plugin Settings

The plugin adds a settings page at Settings โ†’ PostPenguin with:

  • Secret Key โ€” Your shared secret for webhook verification
  • Webhook URL โ€” The URL to enter in PostPenguin (displayed automatically)
  • Status โ€” Shows whether the plugin is configured correctly

Your webhook URL will be:

https://your-site.com/wp-json/postpenguin/v1/posts

๐Ÿงช Testing Your Setup

After configuring the plugin, test the webhook:

# Generate a test signature
SECRET="your-secret-key"
PAYLOAD='{"postPenguinId":"test_123","title":"Test Post","slug":"test-post","contentHtml":"<p className="text-gray-700">Test content</p>"}'
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET" | cut -d' ' -f2)

# Send test webhook
curl -X POST https://your-site.com/wp-json/postpenguin/v1/posts \
  -H "Content-Type: application/json" \
  -H "X-PostPenguin-Secret: $SIGNATURE" \
  -d "$PAYLOAD"

If successful, you'll see a response like:

{
  "success": true,
  "postId": 123,
  "postUrl": "https://your-site.com/test-post/",
  "action": "created"
}

๐Ÿ”ง Advanced: Custom Integration

If you prefer to build your own integration instead of using the plugin, you can create a custom webhook handler:

<?php
// Add to your theme's functions.php or a custom plugin

add_action('rest_api_init', function () {
    register_rest_route('postpenguin/v1', '/posts', [
        'methods' => 'POST',
        'callback' => 'handle_postpenguin_webhook',
        'permission_callback' => '__return_true'
    ]);
});

function handle_postpenguin_webhook(WP_REST_Request $request) {
    // Verify signature
    $signature = $request->get_header('X-PostPenguin-Secret');
    $secret = get_option('postpenguin_secret_key');
    $body = $request->get_body();
    
    $expected = hash_hmac('sha256', $body, $secret);
    if (!hash_equals($expected, $signature)) {
        return new WP_Error('unauthorized', 'Invalid signature', ['status' => 401]);
    }
    
    $data = json_decode($body, true);
    
    // Create WordPress post
    $post_id = wp_insert_post([
        'post_title' => sanitize_text_field($data['title']),
        'post_name' => sanitize_title($data['slug']),
        'post_content' => wp_kses_post($data['contentHtml']),
        'post_status' => 'publish',
        'post_type' => 'post',
    ]);
    
    if (is_wp_error($post_id)) {
        return new WP_Error('error', 'Failed to create post', ['status' => 500]);
    }
    
    // Save PostPenguin ID for future updates
    update_post_meta($post_id, '_postpenguin_id', $data['postPenguinId']);
    
    return [
        'success' => true,
        'postId' => $post_id,
        'postUrl' => get_permalink($post_id)
    ];
}

๐Ÿ› Troubleshooting

Plugin not appearing in WordPress admin

  • โ€ข Check that the file is named postpenguin.php
  • โ€ข Verify it's in the wp-content/plugins/ directory
  • โ€ข Check PHP version is 7.0 or higher

"Invalid signature" error

  • โ€ข Ensure the secret key in WordPress matches PostPenguin exactly
  • โ€ข Check for extra spaces or line breaks in the secret key
  • โ€ข Verify the webhook URL is correct

Posts not appearing

  • โ€ข Check Posts โ†’ All Posts in WordPress admin
  • โ€ข Look for posts with status "Published"
  • โ€ข Check WordPress error logs for any issues

403 Forbidden or REST API errors

  • โ€ข Ensure WordPress permalinks are enabled (Settings โ†’ Permalinks)
  • โ€ข Check if a security plugin is blocking REST API requests
  • โ€ข Verify your server allows POST requests to the REST API

๐Ÿ“š Plugin Requirements

  • WordPress 5.0 or higher
  • PHP 7.0 or higher
  • REST API enabled (enabled by default in WordPress)
  • HTTPS recommended for security

Need Help?

Check our webhook documentation for technical details, or contact support for custom integrations.