WordPress.org

Forums

WordPress Sphinx Search Plugin
Filtering post types (3 posts)

  1. kellbot
    Member
    Posted 1 year ago #

    We are using bbpress and a few other plugins, and I'd like to be able to choose whether or not to include the "forum" post type when searching. We also have some internal-use-only post types I would prefer not to index at all.

    Where can I customize or filter those? I'm poking around in the code but not sure where to start.

    https://wordpress.org/plugins/wordpress-sphinx-plugin/

  2. kellbot
    Member
    Posted 1 year ago #

    I managed to filter out the stuff I didn't want by adding a link to the sphinx config explicitly including only the ones I did.

    p.post_status = 'publish' \
            group by p.ID

    becomes

    p.post_status = 'publish' and \
    	p.post_type IN ('post', 'topic', 'reply', 'page') \
            group by p.ID

    Since I don't see any filters / hooks in the plugin I guess I'll have to fork it to support selectors for custom post types.

  3. kellbot
    Member
    Posted 1 year ago #

    I managed to add filters for my custom post types with a few tweaks to the plugin code.
    The basic process, for anyone who wants to do it on their own:

    Modify sphinx.conf to include a new attribute, isForum (or whatever post type) and edit all four sql statements to query this post type.

    Edit /wordpress-sphinx-plugin/php/sphinxsearch_frontend.php and mimic the structures used for comment/post/page/tag filtering. There are a handful of places this needs to be done.

    Edit the widget/panel template files to include the appropriate checkboxes.

    Obviously these changes will be lost on update, so right now I'll have to hand-merge updates. I'm going to try to write a few hooks that would make this a more generic process for others, if you're accepting mods to the plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress Sphinx Search Plugin
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic