Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to get_post result before indexing #394

Open
jhned opened this issue Jan 17, 2019 · 1 comment
Open

Add filter to get_post result before indexing #394

jhned opened this issue Jan 17, 2019 · 1 comment

Comments

@jhned
Copy link
Contributor

jhned commented Jan 17, 2019

$post = get_post( $post_id );

I'm in a situation where I have many posts that have discrete, specific names. On the front-end, I filter the post title to merge the current post title with parent post titles in order to provide more context. I don't want to change the post title itself in the database, because I need to keep the data as close to the original source as possible.

For that reason, I'm looking for a way to filter the post information before indexing it, so that I can include post parent title information in what gets indexed. One way of doing this would be to filter the post object result of get_post on line 228 of /includes/class-solrpower-batch-index.php.

I'll go ahead and submit a quick pull request, but look forward to other thoughts on the matter.

@pavellishin
Copy link
Contributor

pavellishin commented May 16, 2019

Have you considered using the solr_build_document hook? https://github.com/pantheon-systems/solr-power/blob/master/includes/class-solrpower-sync.php#L396 <-- build_document runs the resulting solr doc and the WP post through this filter before submitting it for a solr update.

We're using it in our project to strip some content out of the body of the post, but you could use it to modify the post title as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants