TG Publisher
A powerful WordPress plugin that seamlessly integrates with Telegram Bot API to automatically publish your WordPress content to multiple Telegram channels.
by Reza Qalekhani · github.com/reza-qalekhani/wp-telegram-publisher · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/reza-qalekhani/wp-telegram-publisher/archive/refs/heads/main.zipSend WordPress posts and pages to Telegram channels with custom content support. Automate your content distribution and reach your Telegram audience directly from your WordPress dashboard.
📝 Description
WP Telegram Publisher is a powerful WordPress plugin that seamlessly integrates with Telegram Bot API to automatically publish your WordPress content to multiple Telegram channels. Perfect for content creators, news outlets, and businesses looking to expand their reach across Telegram while maintaining a single source of truth in WordPress.
The plugin provides flexible message templating, support for featured images, inline buttons with styling options, and comprehensive logging to track all message deliveries.
✨ Features
- 🔄 Automatic Publishing — Automatically send posts and pages to configured Telegram channels when they're published
- 📱 Multiple Channels — Support for multiple Telegram channels with individual channel configurations
- 📝 Custom Templates — Create and manage custom message templates with placeholder support ({title}, {excerpt}, {url})
- 🖼️ Featured Images — Automatically include featured images in Telegram messages as photos
- 🔗 Inline Buttons — Add "Read More" buttons with customizable styling options:
- Default
- Primary (Blue)
- Success (Green)
- Danger (Red)
- ✋ Manual Sending — Send posts to Telegram on-demand from the WordPress editor
- 🚫 Per-Post Control — Exclude individual posts from being sent to Telegram
- 📊 Message Logging — Comprehensive logging with timestamps to track all message deliveries and errors
- 📦 Multi-Type Support — Send any public post type (posts, pages, custom post types)
- 🌍 Internationalization — Full translation support (includes Persian/Farsi)
- 🔧 Custom API Base URL — Support for custom Telegram API endpoints
- 👤 Per-Channel Footers — Add custom footers to messages on a per-channel basis
- ⚙️ Flexible Configuration — Configurable from WordPress admin with intuitive settings page
💻 Requirements
- PHP: 7.0 or higher
- WordPress: 5.0 or higher
- Telegram Bot: A valid Telegram Bot Token (obtainable from @BotFather)
- Telegram Channel: Channel access with permissions to publish messages
🛠️ Installation
- Download the plugin files
- Upload the
wp-telegram-publisherfolder to/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to Settings → TG Publisher to configure your Telegram bot and channels
⚙️ Configuration
1. Telegram Bot Setup
First, create a Telegram bot by talking to @BotFather:
- Start a conversation with @BotFather
- Send
/newbotcommand - Follow the prompts to create your bot
- Copy the API token provided
2. Plugin Settings
Go to Settings → TG Publisher in your WordPress admin to configure:
Essential Settings
- Telegram Bot Token — Your bot's API token from @BotFather
- Channels — Add one or more Telegram channels:
- Channel Name (display name)
- Channel ID (chat ID, typically starts with
-100) - Channel Footer (optional custom footer text)
- Post Types — Select which post types should be sent to Telegram
- Read More Text — Customize the button text (default: "Read More")
- Button Style — Choose the inline button styling
Advanced Settings
- Telegram API Base URL — Use a custom Telegram API endpoint (default:
https://api.telegram.org)- Useful for custom API implementations or proxy setups
3. Message Templates
The plugin includes a default template with the following placeholders:
<b>{title}</b>
{excerpt}
<i>Read full article:</i> {url}
Available placeholders:
{title}— Post title{excerpt}— Post excerpt{url}— Post URL/link{content}— Full post content (when applicable)
4. Finding Your Channel ID
To get your Telegram channel's chat ID:
- Create/use your Telegram channel
- Add your bot as an administrator
- Send a message to the channel
- Visit:
https://api.telegram.org/bot{YOUR_BOT_TOKEN}/getUpdates - Look for the chat ID (usually starts with
-100)
🚀 Usage
Automatic Publishing
Once configured, every time you publish a new post or page:
- The plugin checks if it should be sent to Telegram
- Generates the message from the template
- Includes the featured image (if set)
- Adds the "Read More" button with the post URL
- Sends to all configured channels
Manual Sending
To manually send a post to Telegram:
- Open the post editor
- Find the Telegram Publisher meta box (right sidebar)
- Click "Send to Telegram Now" button
- Check the result message
Excluding Posts
To exclude a specific post from being sent to Telegram:
- Open the post editor
- In the Telegram Publisher meta box
- Check "Exclude from Telegram"
- Save the post
Checking Message Status
The plugin shows the current status of each post:
- Sent to Telegram (green) — Message successfully delivered
- Excluded from Telegram (orange) — Post is excluded
- Error sending to Telegram (red) — Failed to deliver
📁 Project Structure
wp-telegram-publisher/
├── wp-telegram-publisher.php # Main plugin file with headers
├── composer.json # Composer dependencies
├── README.md # This file
├── includes/
│ ├── class-wp-telegram-publisher.php # Main plugin class
│ ├── class-wp-telegram-publisher-settings.php # Settings page handler
│ └── class-wp-telegram-publisher-api.php # Telegram API integration
├── assets/
│ ├── css/
│ │ └── admin.css # Admin interface styles
│ ├── js/
│ │ └── admin.js # Admin interface JavaScript
│ └── worker/
│ ├── index.php # Worker script
│ └── content.txt # Worker content
├── languages/
│ ├── wp-telegram-publisher.pot # Translation template
│ ├── wp-telegram-publisher-fa_IR.po # Persian translation
│ └── wp-telegram-publisher-fa_IR.mo # Persian translation (compiled)
└── vendor/
└── ... # Composer dependencies
🏗️ Architecture
The plugin follows a modular, object-oriented architecture:
Core Components
-
Main Plugin Class (
WP_Telegram_Publisher)- Initializes the plugin
- Manages post status transitions
- Handles meta box rendering
- Manages AJAX requests
-
Settings Handler (
WP_Telegram_Publisher_Settings)- Registers plugin settings
- Renders the settings page
- Handles configuration form submissions
-
API Integration (
WP_Telegram_Publisher_API)- Communicates with Telegram Bot API
- Sends messages and photos
- Logs all message attempts
- Handles errors and responses
Data Storage
Database Tables:
-
wp_telegram_publisher_logs — Message sending history with timestamps
- Channel ID and name
- Message type (text, photo, with/without buttons)
- Message content
- Delivery status
- Error messages
-
wp_telegram_publisher_templates — Message templates
- Template name
- Template content
- Default template flag
WordPress Options:
wp_telegram_publisher_bot_token— Bot API tokenwp_telegram_publisher_channels— Channel configuration arraywp_telegram_publisher_post_types— Selected post typeswp_telegram_publisher_read_more_text— Button textwp_telegram_publisher_button_style— Button stylingwp_telegram_publisher_api_base_url— Custom API endpoint
🔌 API & Integrations
Telegram Bot API
The plugin integrates with the Telegram Bot API using:
- sendMessage — For text messages with optional buttons
- sendPhoto — For messages with featured images
WordPress Hooks & Filters
Actions:
transition_post_status— Triggered when post status changes (publish/draft)wp_telegram_publisher_send_to_channels— Custom action for sending messageswp_ajax_send_post_to_telegram— AJAX handler for manual sendingwp_ajax_get_template_content— AJAX handler for template preview
Filters:
The plugin respects standard WordPress filters for post data extraction.
🌍 Internationalization
The plugin is fully internationalized with:
- Text domain:
wp-telegram-publisher - Language files location:
/languages/ - Currently supported: English, Persian (Farsi)
Translation Files
wp-telegram-publisher.pot— Translation template for translatorswp-telegram-publisher-fa_IR.po— Persian source translationswp-telegram-publisher-fa_IR.mo— Persian compiled translations
To add new language support, create a .po file in the /languages/ directory following WordPress translation conventions.
🧪 Development
Project Files Overview
- wp-telegram-publisher.php — Main plugin file (plugin header, initialization, database setup)
- class-wp-telegram-publisher.php — Core plugin functionality
- class-wp-telegram-publisher-settings.php — Settings page and configuration
- class-wp-telegram-publisher-api.php — Telegram API communication
- admin.js — Admin interface interactivity
- admin.css — Admin interface styling
Database Setup
The plugin automatically creates/upgrades necessary database tables on activation:
wp_telegram_publisher_logs
wp_telegram_publisher_templates
Testing Locally
- Set up a local WordPress installation
- Create a test Telegram bot via @BotFather
- Configure the plugin with your test bot token
- Create a test Telegram channel/group
- Add the bot to the channel with admin permissions
- Configure the plugin with the channel ID
🚀 Build & Release
Version Management
Current version: 1.2
Plugin files to update for new releases:
wp-telegram-publisher.php— Update version in plugin header and constants- Create/update changelog in documentation
Release Process
- Update version number in
wp-telegram-publisher.php - Test all features thoroughly
- Update documentation if needed
- Commit changes with version tag
🤝 Contributing
Contributions are welcome! When contributing:
- Follow WordPress coding standards
- Test your changes thoroughly
- Ensure internationalization compatibility
- Document new features
📜 License
This plugin is open-source and free to use, modify, and distribute.
📋 Changelog
Version 1.2
- Added inline button styling options (Primary, Success, Danger)
- Implemented message logging with timestamps
- Added support for custom Telegram API endpoints
- Added per-channel footer support
- Improved error handling and reporting
Version 1.1
- Added timestamp index to logs table for better performance
- Enhanced database schema
- Improved stability
Version 1.0
- Initial release
- Basic message sending functionality
- Settings page
- Multi-channel support
👨💻 Author
Reza Qalekhani
- Website: byreza.net
- Channel: @byreza_net
- Telegram ID: @reza_qalekhani
❤️ Show Your Support
If you find this project useful, please:
- ⭐ Give it a star on GitHub
- 🔗 Share it with your network
- 💬 Leave feedback and suggestions
- 🐛 Report bugs and issues
Made with ❤️ by Reza Qalekhani
Last Updated: 2026-06-18