SharePoint Search for WordPress

Use this guide, if you want to embed a SharePoint Online Search experience in a WordPress page or post. Also see the following video

The Content by Search app gives companies that use WordPress as their intranet platform of choice a simple solution to offer employees the ability to search for any type of content – from documents and tasks to people – by tapping into the potential offered to us by Microsoft SharePoint Online.

The WPO365 | LOGIN plugin includes a basic version of the Content by Search app. Intranet managers that require the ability to highly customize this experience, however, can obtain an advanced version of the app through the WPO365 | M365 extension of WPO365 | INTRANET bundle.

Before you start

  • You must already have configured the single sign-on capability of the WordPress + Office 365 plugin.
  • Additionally, you must also already have configured the integration capability of the plugin.
  • You are a Global Administrator for your company’s Office 365 tenant / Azure AD directory (or have at least the ability to edit the Azure Active Directory App registration that was created previously when the single sign-on capability was configured).
  • You are an Administrator for your WordPress website.

App registration

  • In Azure Portal click the 'hamburger' (icon with three horizontal lines in the upper corner) to open the menu.
  • Navigate to Azure Active Directory > App registrations.
  • Select the App registration that you created when you configured the single sign-on capability of the plugin.

API Permissions

  • Click API permissions from the 'App registration' menu on the left
  • Click + Add a permission.
  • Select SharePoint > Delegated permissions.
  • Check
    • Sites.Search.All
  • Click  Add permissions.
  • Click Grant admin consent for … as an administrator for to grant consent for all users in your tenant to use this ‘App registration’.

Please note Optionally you can add the following permission to allow the Content by Search short code generator to automatically discover your SharePoint home address e.g. If you don't add this permission, you must enter your SharePoint home address manually.


  • Navigate to WP Admin > WPO365 > Integration.
  • Click Delete tokens.
  • Click Save configuration.
  • Sign out of your WordPress website.
  • Now sign in again with Microsoft.

Please note Deleting tokens and then signing out and in again will ensure that the access token that the plugin retrieves on your behalf has all the right permissions. It may also be a good idea to clear your browser's cache for the website.

Generate a Content by Search short code

To generate a short code to embed the Content by Search (SharePoint) app into any WordPress page or post, navigate to WP Admin > WPO365 > ... > Content by Search (SharePoint) and configure (some of the) following options.

Basic edition
  • Your SharePoint Home URL is be set to the home URL of your SharePoint Online tenant e.g. where you should replace the your-tenant with (host) name that is specific to you. Please note that if you added the Sites.Read.All delegated permission to your (primary or secondary) Azure AD App registration, the Content by Search (SharePoint) short code generator will try and figure this address out all by itself. If you did not add this permission, you might see a popup, informing you that you must enter this information manually.
  • Click Copy short code to clipboard.

Now continue to the next section Embed a Content by Search (SharePoint) app in a WordPress page or post.

Intranet edition

  • Select result source let you switch between SharePoint Online search result sources. Result sources limit searches to certain content or to a subset of search results. Refer to the official Microsoft documentation for instructions on how to manage result sources. The plugin supports all possible result source but has been pre-configured for two:
    • Local SharePoint Results is the default result source that covers most generic requirements to find documents and items saved in your SharePoint tenant.
    • Local People Results is a specific result source that covers requirements to find users registered in your SharePoint tenant.
  • Result source ID is automatically set if you choose the Local SharePoint Results or the Local People Results result sources from the previous drop down list or can be entered manually if you want to use a different / custom result source that is not in the list.
  • Use (Handlebars) template allows you to fully customize how your search results are rendered / presented to your users. The option to use templates has been added since v9.5 and are now the preferred way to render search results. However, you can still uncheck this option and use the legacy placeholders for primarysecondarytertiary and meta text. Refer to the following online documentation for instructions on how to create your own fully custom Handlebars template.
  • Template (only visible when you checked Use (Handlebars) template) allows you to configure the location where the app should try and download the (custom) Handlebars template from. Please note that for reasons of security modern browsers won’t allow you to download content from other servers than your own (unless CORS has been properly set up). By default the shortcode generator proposes to use the Handlebars template that ships with the plugin.
  • Primary / Secondary / Tertiary / Meta text (only visible when you unchecked Use (Handlebars) template) allows you to connect the built-in static template’s Primary / Secondary / Tertiary / Meta text placeholders with a so-called SharePoint Search Managed Property. Read the Select properties section further down for information on how to retrieve these Managed Properties.
  • Try retrieve user photo tells the app to try and connect to Microsoft Graph and download a user’s Office 365 profile image whenever if finds the Managed Property UserName among the Managed Properties returned for a search result item.
  • Query template allows you to take control of the query entered by the user (if any) using a template that will replace the original query text. Doing so would help you limit the results that are returned by the app. For example the following query template would only return results found in the Shared Documents library in the Contoso Site Collection: Path:%22 {searchterms}
  • Auto search tells the plugin not wait for the user to enter a search query but instead start and search immediately. This is especially usefull when used in combination with a Query Template and / or Add wildcard to each search term (see below).
  • Select properties can be used to request additional Managed Properties to be included for each search result item. Please refer to the Microsoft documentation to gain an understanding of how you can manage the SharePoint Online search schema. If you’d like to experiment hands-on with SharePoint search then please consider downloading the SharePoint Search Query Tool.
  • Results per page allows you to restrict the number of results displayed per page.
  • Min. input length tells the plugin to wait before executing the search query entered by the user until at least a minimal number of characters has been entered into the search box. This setting does not prevent Auto search from executing a search immediately as soon as the app has finished loading.
  • Add wildcard to each search term adds an * (asterix) to each word that the user enters into the search box and will therefore change the behaviour of the app significantly by instructing the app to search in SharePoint for content that contains the query text entered by the user (instead of returning only items that match exactly with the query text entered by the user).
  • Hide Search box / Message bar / Paging will hide the corresponding elements when checked. This is especially usefull when used in combination with an Query template and Auto search.
  • Sort list tells SharePoint to sort the results according to the specific Managed Property entered here. Please note that not all Managed Properties are sortable (see manage the SharePoint Online search schema).
  • Click Copy short code to clipboard.

Embed a Content by Search (SharePoint) app in a WordPress page or post

Perform the following steps to embed the Content by Search (SharePoint) app in a WordPress page or post after you clicked to Copy the short code to clipboard.

  • From the WordPress Admin Bar, click + New to add a new WordPress page or post.
  • On the page or post, type short code in the block navigator and click the short code shortcut to add a new short code block to the page or post.
  • In the short code editor, click Ctrl+V (or right mouse click and click Paste) to paste the short code.
  • Publish the page and then click View post to check the result.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us