WordPress.org

Forums

Relevanssi - A Better Search
[resolved] Restrict search to post titles only? (7 posts)

  1. Jaya
    Member
    Posted 3 years ago #

    My website relies on the search feature a lot and I would like to restrict that to post titles only as that's all what matters to my website's users.

    Is this doable? Would that lower the memory usage in my server?

    Any help would be appreciated! Thank you in advance for such an amazing plugin!

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

  2. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    I just did that for another user of Relevanssi. Here's a function that'll make post body count less: Making post body not count. Small adjustment to that will make only titles count. Using that function will require the Premium version of Relevanssi, though.

    Of course to take it a bit further, one would need to prevent the indexing of anything but the titles. That isn't currently possible without hacking the source code, but adding filters to make it possible is on my list of things to do.

  3. Jaya
    Member
    Posted 3 years ago #

    Thank you for your quick response! I'll be watching the plugin's updates and might invest on the premium version once this has been added.

    Have a wonderful day!

  4. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    Hi, I just released the version 1.5.5 of Relevanssi Premium, which includes the necessary filters. Not including post content makes the search database much leaner and should make things easier on server memory and processor.

  5. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    I'm probably not going to add this feature to the free version, but it's fairly easy to hack if you want it and don't mind making the changes every time you update. Here's how:

    In relevanssi_index_doc() function, find this line:

    $contents = relevanssi_tokenize($contents);

    and replace it with

    $contents = array();

    That'll prevent Relevanssi from tokenizing and indexing post content.

  6. Jaya
    Member
    Posted 3 years ago #

    That code worked great! Thank you!

    what's the difference between the premium version's implementation and the code you posted?

    Appreciate your support!

  7. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    The Premium version has a filter that can be turned on and off without changing the code. This will be overwritten when you upgrade, the premium version lets you do the change outside Relevanssi code.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags