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

Document coauthors_plus_should_query_post_author filter #319

Closed
mjangda opened this issue Nov 24, 2015 · 2 comments
Closed

Document coauthors_plus_should_query_post_author filter #319

mjangda opened this issue Nov 24, 2015 · 2 comments

Comments

@mjangda
Copy link
Member

mjangda commented Nov 24, 2015

We should document this somewhere easily accessible:

If the site is using Co-Authors Plus and has a large database, you may run into issues with heavier than usual queries. You can work around this by disabling compat mode and force it to use simpler, tax-only queries by adding the following to your theme:

// Use simple tax queries for CAP to improve performance
add_filter( 'coauthors_plus_should_query_post_author', '__return_false' );

Note that this requires the site(s) to have proper terms set up for all users. You can do this with the following wp-cli command:

# This is pretty long-running and can be expensive; be careful!
$ wp --url=example.com co-authors-plus create-terms-for-posts

Some background in #111. More details below:

Co-Authors Plus creates a matching term for each author on the site and when you assign an author to a post, you're associating that authors term with the post. However, by default, the plugin defaults queries to lookup using both the term AND the post_author column. This is to catch any posts that were added before the plugin was enabled and may not the proper author terms associated. The downside to this is that the queries tend to be very expensive. These are typically only in the admin and on author archives, which don't get a lot of traffic. But for sites that do traffic author archives more heavily or run author queries in other places start to see a slowdown in query performance as the sites grows.

The workaround noted in this ticket switches to term-only queries using the filter. The script can go and backfill terms for older posts so that they're included in results.

For large sites, where visibility of older posts on author archives and other author queries is not an issue, it's suggested to enable the filter immediately and then run the backfill script off-hours. If visibility for those posts is important, the script should be run before the filter is added.

@mjangda
Copy link
Member Author

mjangda commented Nov 24, 2015

I guess readme is probably the best place to it for now.

@sboisvert sboisvert added this to the 3.2 milestone Dec 21, 2015
@mjangda mjangda mentioned this issue Dec 21, 2015
@benhutchins
Copy link

This may hit what appears to be a larger issue, that the readme.txt appears to be bloated. Should this be broken into README.md, CONTRIB.md, CHANGELOG.md, and INSTALL.md. Then this specific issue would be noted in INSTALL.md.

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

No branches or pull requests

4 participants