Hoping this isn't already asked/answered, but it's a tough one to search. I've got a site based on the Flatsome theme which uses custom post types (through various plugins). The search page works in that it returns the right pages/posts/users (using Relevanssi).
However, in content.php within our child theme, we have custom code that displays special content in results for users (members). This code works for most users, but for some the post type seen is either "blocks" or product_variation
(we're using WooCommerce). This snippet is slightly modified to simply output what we're seeing in the search results for the problem records; all I'm doing, really, is using get_posts()
to load up info about the page/post/user so I can display the object appropriately:
$post_info = get_post(get_the_ID());
$user_id = ($post_info->post_type == 'user') ? $post_info->user_id : $post_info->ID;
echo "Record is a " . $post_info->post_type . " with ID " . $user_id . "<br />";
This displays the following before the search result that is a user:
Record is a blocks with ID 542
I've worked around this by treating these users as users if their post_type
is user
, blocks
, or product_variation;
but something must be amiss.
I debugged this by putting extra code in the Relevanssi plugin to output the search results (the return from relevanssi_do_query()
). The problem record I've been focusing on looks completely fine there, set to "user". But when I output the post type within content.php (retrieved via get_post()
), it displays as blocks. Happy to debug this further, but I've not yet had to debug the WP core this deeply before. Thanks for the help.