Skip to main contentSkip to footer

Setting post_type to page doesn’t work

For some reason setting the post_type query variable to page doesn’t have the desired effect. Other post types (post, custom post types) work, but page doesn’t do anything.

This is not a Relevanssi bug, but a WordPress feature (see this trac ticket). If the user inputs a bad value to the post_type query variable, WordPress changes it to any. For some reason that happens also when the post_type is set to page, even though that should be a valid value.

There’s nothing Relevanssi can do about this. However, there’s a fix. Relevanssi introduces a new query variable post_types, which happily accepts page. Use that, if you need to filter by post type.

(Update 19.1.2021: This WordPress bug still isn’t fixed!)

Your account

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

Search

Popular Resources

A New Chapter for Relevanssi
We are very excited to announce that Relevanssi has found a new home with comesio solutions GmbH, a software company…
Indexing product codes with and without spaces

A Relevanssi Premium customer had a problem with product codes. The codes are in the format “ABC 100”, a group of letters and digits with a space in between. Users may search for the codes without the space, so the post should be found with “ABC 100” or “ABC100”. The……is relatively straightforward and uses the relevanssi_post_content and relevanssi_post_title_before_tokenize filter hooks: add_filter( ‘relevanssi_post_content’, ‘rlv_product_codes’ ); add_filter( ‘relevanssi_post_title_before_tokenize’, ‘rlv_product_codes’ ); /** * Index product codes in the format “ABC 123” ie. group of letters, * a space, group of digits both ways, with or without the space, so * that the……product codes don’t appear in a specific custom field but in the post titles and content. Thus the solution is to check both of those, and whenever something is found that matches the product code pattern, that string is indexed as is, but also with the space removed. The code…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed