{"id":14954930,"url":"https://github.com/danteon0/wordpress-discord-post-integration","last_synced_at":"2025-07-29T17:15:49.346Z","repository":{"id":251204816,"uuid":"836707243","full_name":"Danteon0/wordpress-discord-post-integration","owner":"Danteon0","description":"Post integration between WordPress and Discord platforms","archived":false,"fork":false,"pushed_at":"2024-08-28T11:10:08.000Z","size":109,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T03:11:33.429Z","etag":null,"topics":["discord","discordapp","webhook","webhook-events","wordpress","wordpress-development","wordpress-site","wordpress-theme"],"latest_commit_sha":null,"homepage":"https://emirhankaya.net","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Danteon0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-01T11:47:12.000Z","updated_at":"2025-01-06T12:26:47.000Z","dependencies_parsed_at":"2024-08-14T13:43:56.461Z","dependency_job_id":"d146a09d-20d4-4d8c-adb2-91e80b653164","html_url":"https://github.com/Danteon0/wordpress-discord-post-integration","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"cfc86b362590e6d3af60777383d17480b7622b1f"},"previous_names":["danteon0/wordpress-discord-post-integration"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Danteon0/wordpress-discord-post-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danteon0%2Fwordpress-discord-post-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danteon0%2Fwordpress-discord-post-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danteon0%2Fwordpress-discord-post-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danteon0%2Fwordpress-discord-post-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Danteon0","download_url":"https://codeload.github.com/Danteon0/wordpress-discord-post-integration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danteon0%2Fwordpress-discord-post-integration/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267724007,"owners_count":24134260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","discordapp","webhook","webhook-events","wordpress","wordpress-development","wordpress-site","wordpress-theme"],"created_at":"2024-09-24T13:10:15.333Z","updated_at":"2025-07-29T17:15:49.277Z","avatar_url":"https://github.com/Danteon0.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- Social Media Links --\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://discord.com/invite/eWcNKXmsgw\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Discord-%2300b0ff?style=for-the-badge\u0026logo=discord\u0026logoColor=white\" alt=\"Discord\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://emirhankaya.net\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Website-%23000000?style=for-the-badge\u0026logo=google-chrome\u0026logoColor=white\" alt=\"Website\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://x.com/Danteon0\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Twitter-%231DA1F2?style=for-the-badge\u0026logo=twitter\u0026logoColor=white\" alt=\"X\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[![Discord Presence](https://lanyard.cnrad.dev/api/496393095282294796)](https://discord.com/users/496393095282294796)\n\n# 🤖 WordPress Discord Post Integration\n\nThis project is an example of an integration used to automatically share new blog posts published on your WordPress site in a Discord channel. This way, every new post is automatically sent to the Discord channel you specify, allowing your followers to access the latest content instantly.\n\n## 📜 Prerequisites\n\nTo use this integration, you need the following requirements:\n\n- **WordPress**: This project is designed to work on a WordPress site. You should have an up-to-date version of WordPress.\n- **Discord Account**: You need a Discord account to implement the integration. You also need a Discord server where you want the messages to appear.\n- **Web Server**: Your WordPress site needs to be hosted on a web server.\n\n## 📁 Creating a Discord Webhook\n\nIn Discord, you need to create a webhook to automatically share your WordPress posts. The webhook provides a URL to send messages to your Discord server. Here are the steps to create a webhook:\n\n1. **Log in to Discord Server**: Open your Discord application and select the relevant server.\n2. **Create Webhook**: Go to the server settings, click on the \"Integrations\" tab, and select \"Create Webhook\".\n3. **Copy the Webhook URL**: Copy the URL provided for the created webhook. This URL will be used in the WordPress integration code.\n\n## 📕 WordPress Integration\n\nAfter creating your Discord webhook, you can use it to share posts on your WordPress site. Follow these steps to implement the integration:\n\n1. **Update the functions.php File**: Add the following code to the `functions.php` file in your WordPress theme files.\n\n## 📗 Code for functions.php\n\nBelow is an example PHP code that will automatically send new posts to your Discord channel in WordPress. This code integrates WordPress post submissions to Discord.\n\n```php\n\u003c?php\n\nfunction send_to_discord($title, $author, $date, $content, $link, $image_url, $webhook_url, $author_avatar) {\n    $embed = array(\n        \"title\" =\u003e $title,\n        \"url\" =\u003e $link,\n        \"description\" =\u003e $content,\n        \"color\" =\u003e hexdec(\"7289da\"), //Color code you want in the embed\n        \"footer\" =\u003e array(\n            \"text\" =\u003e \"example.com is subject to copyright\",\n        ),\n        \"image\" =\u003e array(\n            \"url\" =\u003e $image_url,\n        ),\n        \"author\" =\u003e array(\n            \"name\" =\u003e $author,\n            \"icon_url\" =\u003e $author_avatar,\n        ),\n        \"timestamp\" =\u003e $date,\n    );\n\n    $data = array(\n        \"content\" =\u003e \"New Blog Post Published! @everyone\",\n        \"embeds\" =\u003e array($embed),\n    );\n\n    $options = array(\n        'http' =\u003e array(\n            'header'  =\u003e \"Content-type: application/json\\r\\n\",\n            'method'  =\u003e 'POST',\n            'content' =\u003e json_encode($data),\n        ),\n    );\n\n    $context  = stream_context_create($options);\n    $result = file_get_contents($webhook_url, false, $context);\n\n    if ($result === FALSE) {\n        error_log('An error occurred while sending the Discord webhook.');\n    }\n}\n\nfunction discord_webhook_new_post($post_ID, $post) {\n    // Return if already notified\n    if (get_post_meta($post_ID, '_discord_notified', true)) {\n        return;\n    }\n\n    // Run only for published posts\n    if ($post-\u003epost_status !== 'publish' || $post-\u003epost_type !== 'post') {\n        return;\n    }\n\n    $webhook_url = 'WEBHOOK_URL';\n    $title = get_the_title($post_ID);\n    $author = get_the_author_meta('display_name', $post-\u003epost_author);\n    $author_avatar = get_avatar_url($post-\u003epost_author);\n    $date = get_the_date('c', $post_ID);\n    $content = wp_trim_words(get_the_content(null, false, $post_ID), 40, '...');\n    $link = get_permalink($post_ID);\n    $image_url = '';\n\n    if (has_post_thumbnail($post_ID)) {\n        $image_url = get_the_post_thumbnail_url($post_ID);\n    }\n\n    send_to_discord($title, $author, $date, $content, $link, $image_url, $webhook_url, $author_avatar);\n    update_post_meta($post_ID, '_discord_notified', true);\n}\n\nfunction on_save_post($post_ID, $post, $update) {\n    // Run only for published posts\n    if ($post-\u003epost_status === 'publish' \u0026\u0026 $post-\u003epost_type === 'post') {\n        // Add a short delay to ensure the image is fully loaded\n        wp_schedule_single_event(time() + 5, 'send_to_discord_event', array($post_ID, $post));\n    }\n}\n\nadd_action('send_to_discord_event', 'discord_webhook_new_post', 10, 2);\nadd_action('save_post', 'on_save_post', 10, 3);\n```\n\n 2. **Update the Webhook URL:**\n - Replace `YOUR_DISCORD_WEBHOOK_URL` with the webhook URL you created.\n\n## 📕 Sending a Message\nYou are now ready to send messages! You can use the `send_to_discord` function to send instant messages to your Discord channel from anywhere.\n```php\nsend_to_discord($title, $author, $date, $content, $link, $image_url, $webhook_url, $author_avatar);\n```\n\n## Example Post on Discord\n\n![Post](https://github.com/Danteon0/wordpress-discord-post-integration/blob/main/assets/notification.png)\n\n## 📕 Considerations\n**Security**: Do not share your webhook URL with anyone.\n**Debugging**: If the message does not send, check your curl settings and webhook URL. For more support, you can join our Discord server.\n\n## ✉️ Help and Support\nIf you encounter any issues with this integration or need additional assistance, you can get support by joining our Discord server or by going to the GitHub Issues page and creating a support request.\n\n## ✒️ Contributing\nIf you would like to contribute to this project, please follow these steps:\n\n- Fork the project.\n- Make your changes.\n- Send a pull request.\n\n## 📑 License\nThis project is licensed under the MIT License. For more information, please refer to the License File.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanteon0%2Fwordpress-discord-post-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanteon0%2Fwordpress-discord-post-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanteon0%2Fwordpress-discord-post-integration/lists"}