WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Filter Request (w/ solution) (5 posts)

  1. justin_k
    Member
    Posted 1 year ago #

    Hey Mikko,

    I have a small request: would you be willing to stick a filter at the beginning of relevanssi_get_comments(), like:

    if(apply_filters('relevanssi_index_comments_exclude', $postID)) return "";

    This would allow the exclusion of comments on specific posts from being indexed, without needing to exclude the post entirely:

    add_filter('relevanssi_index_comments_exclude', 'jgk_relevanssi_excludecomments');
    function jgk_relevanssi_excludecomments($postID)
    {
        if($postID == 6493) return true;
    }

    It'd be much appreciated. I really like the ability to index comments, but I have just ONE page with a ridiculous number of comments (thousands), the indexing of which makes search time blow up from ~1s to >30s. By just excluding those, I could continue to enjoy comment-indexing in general without the penalty of just that one page.

    Thanks in advance! :)

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Sure, why not. I'll add this to the next version.

  3. justin_k
    Member
    Posted 1 year ago #

    Excellent, thanks :)

  4. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Small change, though, to your code. I think the correct form for this is

    apply_filters('relevanssi_index_comments_exclude', false, $postID);

    That is, the first argument is the boolean value to filter, and the second argument is a parameter value to guide the filter (aka. the post ID).

  5. justin_k
    Member
    Posted 1 year ago #

    Ah yes - right you are :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.