This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'relevanssi_modify_wp_query', 'rlv_date_query' ); | |
function rlv_date_query( $query ) { | |
$time = strtotime( $query->query_vars['s'] ); | |
if ( $time ) { | |
$year = date( 'Y', $time ); | |
$use_year = strpos( $query->query_vars['s'], $year ) !== false ? true : false; | |
$month = date( 'm', $time ); | |
$day = date( 'd', $time ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Save this as searchwp-live-ajax-search/search-results.php inside your theme. | |
*/ | |
?> | |
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); if ( 'draft' === $post->post_status ) continue; ?> | |
<?php $post_type = get_post_type_object( get_post_type() ); ?> | |
<div class="searchwp-live-search-result" role="option" id="" aria-selected="false"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add this to your theme functions.php (or preferably in a custom plugin, because a theme | |
* update will overwrite the functions.php. | |
* | |
* You can also try different locations by replacing the 'generate_before_entry_title' with | |
* one of the following: | |
* | |
* - generate_after_entry_title |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'save_post', 'relevanssi_remove_duplicate_postmeta', 100 ); | |
function relevanssi_remove_duplicate_postmeta( $post_id ) { | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | |
return; | |
} | |
$pins = get_post_meta( $post_id, '_relevanssi_pin', false ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'relevanssi_content_to_index', 'rlv_pdfjs_content', 10, 2 ); | |
function rlv_pdfjs_content( $content, $post ) { | |
$m = preg_match_all( '/\[pdfjs-viewer url="(.*)"/', $post->post_content, $matches ); | |
if ( $m ) { | |
global $wpdb; | |
$upload_dir = wp_upload_dir(); | |
foreach ( $matches[1] as $pdf ) { | |
$pdf_url = ltrim( str_replace( $upload_dir['baseurl'], '', urldecode( $pdf ) ), '/' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In /lib/install.php, replace the relevanssi_new_blog() function with this: | |
function relevanssi_new_blog( $blog ) { | |
if ( is_int( $blog ) ) { | |
$blog_id = $blog; | |
} else { | |
$blog_id = $blog->id; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'relevanssi_match', 'rlv_customfield_match_filter', 10 ); | |
function rlv_customfield_match_filter( $match ) { | |
global $wp_query; | |
if ( 'listing' === $wp_query->query_vars['post_type'] ) { | |
// This is a listing search. | |
if ( $match->customfield < 1 ) { | |
// No custom fields were hit, set weight to zero. | |
$match->weight = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this to theme functions.php. | |
add_filter( 'relevanssi_custom_field_value', 'rlv_img_alt', 10 ); | |
function rlv_img_alt( $value ) { | |
if ( ! is_array( $value ) ) { | |
$value = array( $value ); | |
} | |
$new_values = array(); | |
foreach ( $value as $value_string ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add this to theme functions.php in order to index information about images and files | |
* linked to the post with the ACF image and file fields. | |
* | |
* Replace the field name with the correct name and choose which parts of the files and | |
* images to index. | |
*/ | |
add_filter( 'relevanssi_content_to_index', 'rlv_acf_image_and_file', 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'relevanssi_content_to_index', 'rlv_relationship_content', 10, 2 ); | |
function rlv_relationship_content( $content, $post ) { | |
global $wpdb; | |
$relationships = unserialize( $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key LIKE 'sidebar_groups_%_people'" ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions | |
if ( ! is_array( $relationships ) ) { | |
$relationships = array( $relationships ); | |
} | |
foreach ( $relationships as $related_post_id ) { |