Replace wp_query with wp_user_query
I'm turning out some subscriber archives and singles (profile pages) in my plugin where I'd also included a 'user-single' template, included via template_include
. I'm experimenting however with trimming some of these templates out of my plugin in order to make it use theme templates. I've instead used locate_template( 'single.php' )
to choose the single template from the active theme. I'm not using the global wp_query
to turn out my content in this case but the page shows a loop based on the query defaults (ten posts).
What I'm wondering is whether I can completely scrap the default query, replacing it with a wp_user_query
into which I can feed the queried user ID. I would like then to filter the_content
to customise the output on that user single. I've tried using pre_get_posts
and even pushing query vars in via my template_include
function ($wp_query-post_type = 'blah'
) but to no avail as the query always eventually falls back to those default ten posts.
Is there a way for me to use the theme page.php (or single.php) template, intercepting the query to replace it with a wp_user_query or does this have to be a custom template job?
Topic wp-user-query template-include pre-get-posts wp-query Wordpress
Category Web