Forums Forums Search & Filter Pro Show only results for author of shortcoded page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #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
    #8925

    Hey 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

    Anonymous
    #8949

    Thanks Ross! Appreciate your help! I just need a way of the only showing the results, categories and tags for the author of the page that the shortcode is placed in.

    Ross Moderator
    #9038

    Hey 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
    #9952

    Hey 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

Viewing 5 posts - 1 through 5 (of 5 total)