Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Add more content to the index for Relevanssi Light

Дата публикации: 20-04-2026 14:26:34



Основное содержимое страницы с новостью.

The main customisation for Relevanssi Light is to add more content to the index. For custom fields, it’s easiest to use the relevanssi_light_custom_fields filter hook. Give the hook an array of custom field names, and the plugin will include the contents of those custom fields in the full-text index.

If you want to add more content, you may need to override the relevanssi_light_update_post_data() function. It’s pluggable so that you can override it from a must-use plugin. Here’s an example plugin that will include the post author’s name in the full-text index:

<?php
/**
 * Plugin Name: Relevanssi Light Override
 * Plugin URI: https://www.domain.com
 * Description: Overrides Relevanssi Light post data update.
 * Version: 1
 * Author: Mikko Saari
 * Author URI: https://www.relevanssi.com/
 * License: GPLv2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 */

if ( ! function_exists( 'relevanssi_light_update_post_data' ) ) {
  function relevanssi_light_update_post_data( $post_id ) {
    global $wpdb;

    // Fetch the author ID and use that to get the author name.
    $author_id = (int) $wpdb->get_var(
      $wpdb->prepare( "SELECT post_author FROM {$wpdb->posts} WHERE ID = %d ", $post_id )
    );
    $author_name = get_the_author_meta( 'display_name', $author_id );

    // Update the post to add the author name to the relevanssi_light_data column.
    $wpdb->update(
      $wpdb->posts,
      array( 'relevanssi_light_data' => $author_content ),
      array( 'ID' => $post_id ),
      array( '%s' ),
      array( '%d' )
    );
  }
}

Save this as a file in the /wp-content/mu-plugins/ folder.

Your account

Not logged in. Log in to see your license details.

SearchPopular Resources
Indexing image alt texts

Relevanssi by default ignores image alt texts (and other tag attributes). That’s often the right thing to do because alt…

Custom weighing with relevanssi_match and relevanssi_results

…} return $match; } Weight from tags Relevanssi Premium has a simple weight setting for adding weight to tags. If you want that in free Relevanssi, you have to use relevanssi_match to add extra weight to tags. add_filter( ‘relevanssi_match’, ‘rlv_boost_tags’ ); function rlv_boost_tags( $match ) { if ( $match->tag >……$title_boost + $match->content + $match->comment * $comment_boost + $match->tag * $tag_boost + $match->link * $link_boost + $match->author + $match->category + $match->excerpt + $match->taxonomy + $match->customfield; $match->weight = $match->tf * $idf; Where $idf is the inverse document frequency, aka the rarity of the term in question. The bigger the weight, the……taxonomy terms Weight from tags Weight from excerpts Weighing multisite subsites More weight for whole word matches Return only comments Weight based on parent Weight for featured images Boost matches from title beginning Performance issues Date-based weight Here’s an example function that will double the weight of posts published within…

Relevanssi indexes excluded posts

Sometimes it can happen the search results include posts from a post type that has been excluded from the index. When that happens, here are things you can check. Are you using Relevanssi? It’s possible your search results are not coming from Relevanssi. The quickest way to check is to…

Related Posts:
Comment Section:

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1A New Chapter for Relevanssi01027-03-2026
2A New Chapter for Relevanssi – Frontpage01027-03-2026
3The wrong content gets indexed for a post06.2227-01-2026
4Подсветка рейки01023-05-2024
5Disabling Relevanssi Light for a specific post type09.0420-04-2026
6Removing Relevanssi from the quick edit04.702-03-2026
7comesio solutions – The new home of Relevanssi01027-03-2026
8Retro Rewind (VHS rental shop sim) adding game rentals this Fall01005-08-2026
9Минфин настаивает на введении НДПИ на попутный газ0019-02-2020
10LISTA: Talangerna som kan lyfta i Brynäs0530-06-2026

Классификация: Пресс-релизы. Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 10. Источник: www.relevanssi.com.