Continue reading Polylang attachment searching

Polylang attachment searching

…you can either enable “Media translate” so that your media files have a language, or you can use this code in your theme functions.php to always include attachments in the results: add_filter( ‘relevanssi_where’, function( $query ) { global $wpdb; $query = str_replace( ‘AND relevanssi.doc’, ‘AND ( relevanssi.doc’, $query ); $query…If Polylang is in use and you haven’t enabled “Media translation“, your attachment files won’t have a language. That’s fine, except when Relevanssi searches fail to find your attachment because they’re looking for posts in a specific language. Suppose you want to include attachments in Polylang searches. In that case,…

Read more Polylang attachment searching 0 Comment on Polylang attachment searching
Continue reading Oxygen and Ninja Tables

Oxygen and Ninja Tables

Relevanssi has support both for Oxygen and Ninja Tables, but the way the Ninja Tables support is done, it’s not working when used with Oxygen. The Ninja Tables support in Relevanssi is looking for the Ninja Tables shortcodes in the post content, but Oxygen keeps everything in custom fields. Fortunately, the fix is simple: you…

Read more Oxygen and Ninja Tables 0 Comment on Oxygen and Ninja Tables
Continue reading MemberPress Downloads add-on

MemberPress Downloads add-on

The Downloads add-on for MemberPress adds downloadable files to MemberPress. These files are stored outside the Media Library, so by default Relevanssi attachment indexing has no access to them. However, Relevanssi offers filter hooks you can use to make Relevanssi index the MemberPress Downloads files. Adjust the query First, we need to tell Relevanssi to…

Read more MemberPress Downloads add-on 0 Comment on MemberPress Downloads add-on
Continue reading Download Monitor: Index PDF content for parent page

Download Monitor: Index PDF content for parent page

Relevanssi can handle Download Monitor files without significant problems. If you want to use the “Index PDF contents for the parent page” option, there’s a problem, though. Download Monitor comes in between: the PDF post is attached to the Download Monitor dlm_download post and not the page where the [download]……where the PDF content is added. * * @return string The modified MySQL query. */ function rlv_download_monitor( string $query, int $post_id ) : string { $meta_field_value = get_post_meta( $post_id, ‘download’, true ); if ( $meta_field_value ) { // The [download id=”1234″] shortcode format has one digit in it, so let’s……the method is slightly different: add_filter( ‘relevanssi_pdf_for_parent_query’, ‘rlv_download_monitor’, 10, 2 ); /** * Modifies the attachment content query. * * @param string $query The MySQL query for fetching the attachment content. * @param int $post_id The post ID of the post where the PDF content is added. * * @return…

Read more Download Monitor: Index PDF content for parent page 3 Comments on Download Monitor: Index PDF content for parent page
Continue reading FacetWP

FacetWP

…to manipulate the Relevanssi query FacetWP runs using the relevanssi_modify_wp_query filter hook. Because the FacetWP Relevanssi integration add-on calls relevanssi_do_query() directly, this hook, and several others, are not called. None of the functions added to the relevanssi_modify_wp_query hook run in this case. The solution is to use the facetwp_relevanssi_do_query hook……are not available. Here’s a code snippet that can be used within FacetWP templates to generate and display Relevanssi excerpts for the posts: $query = isset( FWP()->facet->facets[‘search’] ) ? FWP()->facet->facets[‘search’][‘selected_values’] : ”; echo relevanssi_do_excerpt( $post, $query ); Using relevanssi_do_query filter functions with FacetWP There may be occasions where you need…

Read more FacetWP 0 Comment on FacetWP
Continue reading WP Event Manager

WP Event Manager

Using Relevanssi with WP Event Manager requires you to adjust the search process in WP Event Manager a bit. Fortunately, the plugin has good filters you can use. Add this to your site: add_filter( ‘get_event_listings_query_args’, function( $args ) { $args[‘relevanssi’] = true; return $args; } ); This will adjust the……event listing query arguments to switch on the Relevanssi flag, causing Relevanssi to process the results. This way you’ll get the Relevanssi results in the WP Event Manager event listing search. These Relevanssi results will also be cached by the WP Event Manager query caching. Thanks to dustyyy on WP…

Read more WP Event Manager 2 Comments on WP Event Manager
Continue reading WP Download Manager

WP Download Manager

…filter hooks that make it possible to access WP Download Manager files. Changing the attachment query The first one we need is relevanssi_get_attachment_posts_query, which is used to fetch the attachment posts for indexing. By default, Relevanssi looks for posts with the post type attachment, post status inherit and a suitable……MIME type. These all need to be changed, because the WP Download Manager posts have the post type wpdmpro, status of publish and no MIME type. The necessary filter function looks like this: add_filter( ‘relevanssi_get_attachment_posts_query’, ‘rlv_wpdmpro_query’ ); function rlv_wpdmpro_query( $query ) { return str_replace( “post_type = ‘attachment’ AND post_status =……these issues. When you upload the files to the Relevanssi attachment reading server, Relevanssi uses the get_attached_file() function to get the file name, but that does not work with WP Download Manager. Thus we need to use the relevanssi_get_attached_file filter hook to provide the file name and path for Relevanssi….

Read more WP Download Manager 0 Comment on WP Download Manager