Back to GD bbPress Attachments Forum

Attachments in Relevanssi Search results

Published on: June 8, 2018 at 7:45 pm · By: dickho
Author
Topic
#59226

Hello,

I use Relevanssi premium plugin for search feature on my website. The problem is that uploaded documents on forum appear by default in the search results and this should not be the case, as there are private and absolutely not relevant documents for the website.

How do disable or prevent forum attachments to figure in the search results?

Thanks in advance.
Kind regards.

Viewing 4 replies - 1 through 4 (of 4 total)
Author
Replies
  • #59228

    Hi,

    Attachments are uploaded using Media Library (that is clearly stated in plugin information), so they are part of it. WordPress doesn’t have private files system, so attachments are no exception. I plan to implement really private files for forums, but that will be done only in GD bbPress Toolbox Pro plugin (hopefully by the end of this year).

    Regards,
    Milan

    Dev4Press - Premium plugins for WordPress.

  • #59234

    Hello,

    Thanks for your message.

    In this case, do you have an idea of how to create a filter function that lets through the attachments I want to include, but blocks bbPress attachments? Is there a way to tell from the database entry which attachments should be blocked and which should be allowed?

    If yes, how much would it cost to create?

    Thanks in advance.
    Kind regards.

  • #59235

    That depends on the search plugin, and I have no experience with it. Just match the attachments attached to the topics and replies post type.

    Dev4Press - Premium plugins for WordPress.

  • #59236

    Thanks for your message.

    It’s finally working fine by adding this code in functions.php file:

    add_filter( ‘relevanssi_do_not_index’, ‘rlv_block_forum_attachments’ );
    function rlv_block_forum_attachments( $block, $post_id ) {
    $type = relevanssi_get_post_type( $post_id );
    if ( ‘attachment’ === $type ) {
    $parent_id = wp_get_post_parent_id( $post_id );
    $parent_type = relevanssi_get_post_type( $parent_id );
    if ( ‘reply’ === $parent_type || ‘topic’ === $parent_type ) {
    $block = true;
    }
    }
    return $block;
    }

    Attachements uploaded before adding this code are not affected by this fix

    Kind regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Attachments in Relevanssi Search results’ is closed to new replies.