Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter phoenix

    (@aljosaurleb)

    Answered on Stack Exchange by Rajeev Vyas – Thank You

    You might have to check which button was clicked by user, weather it is search all post or search my post, based on that you can apply filter. Try this..

    function search_author($query) {
    if($query->is_search)
    {
    if($query->query_vars[‘author’]==’Search My Posts’)
    {
    $query->set(‘author’, get_current_user_id());
    }
    }
    return $query;
    }
    add_filter(‘pre_get_posts’,’search_author’);

Viewing 1 replies (of 1 total)