How to Hide a Content Type from New Button Dropdown in SharePoint?
Requirement: Hide a Content Type from the new button drop-down in SharePoint
How to make a Content Type Hidden in SharePoint?
In SharePoint, when you add a new content type to a library, it will be added to the New button dropdown in the ribbon. If you want to hide a content type from the New button dropdown, here is how:
To hide a content type from the new menu in SharePoint,
- Go to List Settings >> Under “Content Types”, click on the “Change new button order and default content type” link.
- Set the “Visible” flag to False by unchecking the tick mark. You can also change New Button Order.
This hides the content type in SharePoint.
SharePoint PowerShell to Hide a Content Type
We can also use PowerShell to hide a content type from the new menu in SharePoint.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Set config variables
$WebURL="https://intranet.crescent.com/"
$ListName ="Projects"
$ContentTypeName="Project Template"
#Get Web and Objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists[$ListName]
#Get the content type
$ContentType = $List.ContentTypes[$ContentTypeName]
$ContentType.Hidden = $True
$ContentType.Update()
Write-Host "Content Type Hidden from the List!"
This hides the content type from the new menu dropdown.
SharePoint Online: Hide Content Type dropdown using PowerShell
Similarly, to hide a content type in SharePoint Online, we can use this PowerShell script:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL="https://crescent.sharepoint.com"
$ListName="Contacts"
$ContentTypeName="Business Contacts"
Try {
#Get Credentials to connect
$Cred= Get-Credential
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the content type from the List
$List = $Ctx.Web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
#Get the content type from list
$ContentTypeColl = $List.ContentTypes
$Ctx.Load($ContentTypeColl)
$Ctx.ExecuteQuery()
#Get the content type to Hide
$CType = $ContentTypeColl | Where {$_.Name -eq $ContentTypeName}
If($CType -ne $Null)
{
$CType.Hidden=$True
$CType.Update($False)
$Ctx.ExecuteQuery()
Write-host "Content Type is Set to Hidden!" -ForegroundColor Green
}
else
{
Write-host "Content Type Doesn't Exist!" -ForegroundColor Yellow
}
}
Catch {
write-host -f Red "Error Setting Conent Type to Hidden!" $_.Exception.Message
}
PnP PowerShell to Hide a Content Type in SharePoint Online List:
Here is how to hide content type from the new dropdown in SharePoint Online.
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$ListName = "Contacts"
$ContentTypeName ="Business Contacts V2"
#Connect to Pnp Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the Context
$Context = Get-PnPContext
#Get the content type from List
$ContentType = Get-PnPContentType -Identity $ContentTypeName -List $ListName
#Set content type to hidden
$ContentType.Hidden = $True
$ContentType.Update($False)
$Context.ExecuteQuery()
The way of hiding same content type in multiple libraries in the site/s
Do you have PnP script for this?
Yes, Article updated with PnP PowerShell!