Title: Filtering posts during Import
Last modified: April 2, 2026

---

# Filtering posts during Import

 *  [ldeschenes](https://wordpress.org/support/users/ldeschenes/)
 * (@ldeschenes)
 * [2 months, 1 week ago](https://wordpress.org/support/topic/filtering-posts-during-import/)
 * Hi Maxell,
 * I’ve always found it valuable for developers to see how their software is used
   in real-world scenarios, so I wanted to share our use case.
 * We manage a homeowners association website composed of three main content types:
    - **Pages** (~250)
    - **Posts** (~1,400 announcements over the past 10 years)
    - **Rules and Regulations** (6 PDF documents)
 * Our objective is to import these into the knowledge base for residents, with 
   some filtering:
    - **Pages**: Only those accessible to residents should be included (excluding
      Property Manager only content).
    - **Posts**: Since announcements are often repetitive, we limit the import to
      the past year to reduce duplication.
    - **Rules and Regulations**: These are handled separately via the PDF sitemap
      import.
 * For Pages and Posts, I’m using the “WordPress Content” importer. To restrict 
   the imported posts, I implemented the mxchat_before_process_post hook with a 
   custom snippet. See below:
 * add_filter(‘mxchat_before_process_post’, function($post, $bot_id) {
 *     ```wp-block-code
       // For pages only: skip if "gestion" is in the URL
       if ($post->post_type === 'page') {
           $permalink = get_permalink($post->ID);
           if ($permalink && stripos($permalink, 'gestion') !== false) {
               return false;
           }
       }
   
       // For posts only: skip if older than 1 year
       if ($post->post_type === 'post') {
           if (strtotime($post->post_date) < strtotime('-1 year')) {
               return false;
           }
       }
   
       return $post;
       ```
   
 * }, 10, 2);
 * This works partially: the content itself is excluded as intended, but entries
   are still created with **null content**, which results in empty indexed items.
 * I can work with that, but would it be possible to adjust the logic so that entries
   with null content are not indexed at all ?
 * Alternatively, a dedicated hook to explicitly exclude posts from indexing might
   be a cleaner approach.
 * I look forward to your thoughts on the best way to handle this.
 * Louis
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffiltering-posts-during-import%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Support [m4xw3ll](https://wordpress.org/support/users/m4xw3ll/)
 * (@m4xw3ll)
 * [2 months ago](https://wordpress.org/support/topic/filtering-posts-during-import/#post-18876687)
 * Hey [@ldeschenes](https://wordpress.org/support/users/ldeschenes/),
 * Thank you for providing this – it’s very insightful. Reviewing it to see how 
   this can be improved and in the next update. I’ll be in touch soon!
 * Thanks,
 * Maxwell

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffiltering-posts-during-import%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/mxchat-basic/assets/icon-256x256.png?rev=3267273)
 * [MxChat - AI Chatbot & Content Generation for WordPress](https://wordpress.org/plugins/mxchat-basic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mxchat-basic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mxchat-basic/)
 * [Active Topics](https://wordpress.org/support/plugin/mxchat-basic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mxchat-basic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mxchat-basic/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [m4xw3ll](https://wordpress.org/support/users/m4xw3ll/)
 * Last activity: [2 months ago](https://wordpress.org/support/topic/filtering-posts-during-import/#post-18876687)
 * Status: not resolved