
Plugin Goal
The goal of the Export Posts to Directory Website plugin is to make it easy for users to export blog posts from their WordPress site to a directory website using the Directory API.
Users who manage both types of websites often find it hard to copy content or create custom solutions to transfer posts. This can take a lot of time and as the process is bit complex which lead to mistakes. The plugin solves this by connecting directly to the Directory API, so there’s no need for manual work or custom development, saving time and reducing errors.
With this plugin, users can export their content quickly and reliably, keeping both websites in sync with minimal effort.
Flexible Export Options
Users have complete control over how and what gets exported:
- Choose to export only new posts, or include updates to existing posts that have already been sent to the directory site.
- Schedule automatic exports, allowing posts to be sent to the directory at specific times without any manual effort.
- Set an export delay, so only posts published before a certain date will be considered for export — ideal for backdated content or controlled release.
- Enable automatic redirection for exported posts. When turned on, visitors to the original WordPress post will be automatically redirected to the corresponding post on the directory website.

The plugin gives users the ability to choose exactly which content should be exported:
- Select specific WordPress categories to include in the export — only posts under these categories will be sent to the directory.
- Choose the post type on the directory website where the content should appear.
- Define the post status after export — posts can be published immediately or saved as drafts for later review.
Passing Post Information Based on Selected Options
The plugin provides users with the flexibility to choose exactly which post information is passed to the directory website. Each data field can be selected or deselected using checkboxes.
- Post Publish Date – If selected, the original publish date of the WordPress post will be included in the export.
- Featured Image – The post’s featured image will be included in the export.
- Post Tags – This option includes all WordPress tags assigned to the post in the export.
- SEO Meta Data – Includes the SEO details: meta title, description, and keywords.
- Post Category – If selected, the plugin will export only the first WordPress category assigned to the post.

Features of Version 1.0
Bulk Export
Quickly export all WordPress posts or update existing exported posts to a directory website with a single click.
Scheduled Exports
Exports can be automated on a daily, weekly, or monthly schedule using WordPress cron jobs, ensuring the directory remains up to date without manual effort.
Individual Exports
The plugin should allow users to control which specific posts they want to export, giving them granular control over the process.

Automatic 301 Redirects
When 301 redirects are enabled, exported WordPress post URLs automatically redirect to their new directory post URLs.
- If Yes is selected, every time a post is exported, a 301 redirect is automatically created from the original WordPress post URL to the new directory post URL. This means visitors who use the old WordPress link will be seamlessly sent to the updated directory page.
- Redirects can also be set individually for specific posts if needed.
This ensures visitors following old WordPress links are seamlessly sent to the correct directory pages without broken links.
API Integration Use Cases
Post Creation Workflow
Each post creation involves two API requests: one to check if the post already exists, and another to create it if it does not.
Directory Post Selection
The plugin fetches single post types from the directory website via the Directory API. This allows selecting the target location on the directory site where the WordPress post should appear.
Missing Categories Detection
The plugin compares WordPress post categories with those on the directory website and displays any missing categories that are not yet created on the directory.
Directory API Validation
Validates whether the provided directory URL and API key are correct and functional.
Author ID Validation
Checks whether the provided author ID is valid on the directory website.
Plugin Performance & Best Practices
Duplicate Post Prevention
Problem Overview
During the export process, the directory website allowed duplicate posts with the same title and URL. This led to multiple identical posts being created.
Implemented Solution
A post ID tracking system was added using the Directory API. When a WordPress post is exported, its corresponding directory post ID is saved in the post meta. Before exporting, the plugin checks if the post already exists on the directory site:
- If it exists, the post is updated.
- If not, a new post is created.
This process uses two API calls per post—one to check and one to create or update—ensuring no duplicate posts are created.
API Rate Limits & Server Timeout
Problem Overview
When exporting a large number of posts, the process failed due to Directory API rate limits. Too many requests in a short time caused the IP address to be temporarily blocked. Additionally, both manual and scheduled exports triggered server timeouts when processing too many posts at once.
Solution Implemented
To handle the API rate limit of 100 requests per minute and reduce server load, two key improvements were made:
Manual Export Optimization
- The number of API requests needed per post is calculated in advance.
- Posts are grouped into smaller batches.
- Each batch is sent with a short delay to stay within the API limit.
- This prevents API blocking and reduces the risk of timeouts during large exports.
Scheduled Export (Cron Job) Optimization
- Uses the same batch processing logic.
- Posts are processed in smaller groups.
- The cron job runs every 60 seconds to ensure a steady, manageable export rate.
- This keeps server usage low and avoids triggering the API’s rate limit.
Code Optimization
Best practices were applied to make the plugin code more secure, maintainable, and performance-friendly:
Output Sanitization
All dynamic content is properly sanitized using WordPress functions like esc_html(), esc_attr(), esc_url(), and wp_kses() based on the context. This helps prevent security issues such as Cross-Site Scripting (XSS) by ensuring that user-generated or dynamic data is safely displayed.
Tools for Achieving Plugin Standards
To ensure the plugin meets WordPress development standards, the following tools were used:
Plugin Check (PCP)
WordPress’s official Plugin Check tool was used to verify that the plugin complies with all requirements for submission to the WordPress.org Plugin Repository. This helped ensure compatibility, security, and adherence to directory guidelines.

PHP CodeSniffer (PHPCS)
PHPCS was used to detect and fix code style issues based on WordPress coding standards. It helped improve code quality, readability, and maintainability, ensuring the plugin follows industry best practices.
Conclusion
The Export Posts to Directory Website plugin streamlines the transfer of posts from WordPress to directory websites using the Directory API. It eliminates manual work, supports flexible export options, and ensures reliable performance with features like duplicate prevention and batch processing. Built according to WordPress coding standards, it offers a secure, efficient, and user-friendly way to keep posts in sync across both platforms.

This Case Study was written by Bharath. Bharath is a skilled developer with expertise in building websites, web applications, and custom plugins. His structured approach to documentation ensures that his work is not only efficient but also valuable to fellow developers. Beyond coding, he brings a fun-loving spirit and a caring nature to the team, making collaboration both productive and enjoyable.