Prince William has become the first member of the royal family to be photographed for the cover of a gay magazine.

The second-in-line to the throne appears in the July issue of Attitude magazine, discussing the mental health implications of homophobic, bi-phobic and transphobic bullyings.

The cover photograph came from a shoot by Leigh Keily taken for the magazine. His mother, Princess Diana, who was patron of the National Aids Trust, appeared on the cover of the Gay Times in a 1997 tribute issue after her death.

The cover of the Attitude edition, which is available for download now, shows a smiling William, wearing a white open-necked shirt, with the caption: “Making history, Prince William meets Attitude.”

The Duke appears on the cover of the June issue of Attitude magazine. Photograph: Attitude/PA

A number of previous cover stars, including the Olympic diver Tom Daley and pop star Harry Judd, of McFly, have appeared topless but the comedian, writer and broadcaster, Stephen Fry, and singer Gary Barlow, appear, like William, fully clothed.

The cover came about after the Duke of Cambridge invited Attitude to bring members of the LGBT+ community to Kensington Palace to hear their experiences of bullying and discuss the impact on mental health.

William, along with the Duchess of Cambridge and Prince Harry, is leading the Heads Together campaign, which aims to end stigma around mental health.

He told Attitude: “No one should be bullied for their sexuality or any other reason and no one should have to put up with the kind of hate that these young people have endured in their lives. The young gay, lesbian and transgender individuals I met through Attitude are truly brave to speak out and to give hope to people who are going through terrible bullying right now. Their sense of strength and optimism should give us all encouragement to stand up to bullying wherever we see it.”

He urged anyone who was being bullied for their sexuality to contact someone whom they could trust, whether a friend, teacher or other adult, or a service such as Childline or the Diana Award. “You should be proud of the person you are and you have nothing to be ashamed of,” the prince said.

Matthew Todd, editor of Attitude, said: “During my time as editor I have met parents whose child has taken or lost their life after being bullied for being LGBT+ or just perceived to be LGBT. I am very happy that the future king of the UK agrees this must stop.”

The issue of Attitude magazine went to press on 8 June, just days before the killing of 49 people at a gay club in Orlando, in the US. On Tuesday, William and Kate signed a book of condolences at the American embassy for victims of the massacre.

The magazine said: “Such violence does not exist in a vacuum but snowballs from intolerance and bullying that begins in classrooms, too often comes from politicians or religious leaders, and is often not treated with respect by the media.”

The print edition featuring William will be in shops next Wednesday.

• This article was amended on 15 June 2016 to correct the fact the Prince William is second-in-line to the throne rather than heir. It was further amended on 14 July 2016 to remove a section that said research had found that “33.9% of young LGB people have made at least one suicide attempt, compared with 17.9% of young straight people, while 48.1% of trans young people have attempted suicide”. These figures came from the PACE charity’s RaRE Research Report which acknowledged that it was possible that there was “a disproportion amongst research participants of people with experience of or who are sensitive towards mental health issues”. A 2009 report from the NHS Information Centre for Health and Social Care gave a figure of 7.3% for the proportion of all 16- to 24-year-olds who had made an unsuccessful suicide attempt.