Forums › Forums › Search & Filter Pro › Show only results for author of shortcoded page
- This topic has 4 replies, 2 voices, and was last updated 9 years, 11 months ago by Ross.
-
Anonymous(Private) December 10, 2014 at 10:58 am #8871
Hi I was wondering what code i would need to add to only show results, categories and tags of the author of the page which the shortcodes are placed in? I am creating a photo sharing website with a social profile and only want visitors to search through each profiles photos only on their page. Hope you can help!!
Thanks
Chris
Ross Moderator(Private) December 11, 2014 at 1:31 pm #8925Hey there
Sorry for the generic message – I got locked out and blacklisted by my host for this website!! – so been unable to login and reply to tickets – playing catchup now – will be systematically working through tickets today.
Thanks
Ross Moderator(Private) December 13, 2014 at 4:34 pm #9038Hey Chris
Just got around to looking at this.
The plugin does not allow for this functionality – I’m having a look to see if you can hook in to the query to modify it yourself and add such parameters but really its out of scope of the plugin.
Thanks
Ross Moderator(Private) January 8, 2015 at 4:23 pm #9952Hey Chris
Although I don’t support it, you should be able to hook in to the query generated by the plugin and modify it using pre_get_posts
This is some sample code which may help (add this to functions.php of your theme) –
function modify_search_filter_query( $query ) { global $sf_form_data; global $wp_query; if ( $sf_form_data->is_valid_form() && $query->is_main_query() && !is_admin()) { //we can add our modifications here: $authorID = 1; $query->set('author', implode(",", $authorID)); //not necessary but we can match the search form ID in case we are using multiple search forms /*if($sf_form_data->form_id()==797) { }*/ } } add_action( 'pre_get_posts', 'modify_search_filter_query', 21 );
Thanks
-
AuthorPosts