Customizing ‘Content Query Webpart ItemStyle’ using XSLT in SharePoint 2013

Share Point 2013 has many out-of-the-box web parts and one  of them, i.e. a widely used  web part is Content Query Web Part (CQWP). ContentByQuryWebpat referred to as Content Query Web Part (CQWP) is used to display content using query/filter from another site or sub-site within the same site collection. With the CQWP, content display as per the requirement, branding and context can be controlled. CQWP style sheets reside in a folder “XSL Style Sheets” in the Style Library. ItemStyle.xsl file named under “XSL Style Sheets” folder contains the style templates which can applied on-the-fly to the items returned by CQWP.

Create custom style by making a copy of ItemStyle.xsl file and make changes as required to it. Upload the customized xsl file to the style library and publish it.

Note :  The Content Query Web Part is only supported in publishing sites. So, you must have the publishing features enabled to make use of it.


  • Aggregate data only within a single site collection.
  • Aggregate only list information.

Imagine that we have a requirement to display list data across sub-sites in a site collection. For instance we need to make use of a list to retrieve respective employee biographies across sub-sites in a site collection. Let me explain the scenario:

For instance the below hierarchy of share point site collections:


The requirement is to display upcoming events from a calendar in all sub-sites under communities’ site collection. We have a column named community which is used to filter and type will be choice in the same calendar list which is created as “Upcoming events” at communities site collection level. Please see the below picture for reference:


g3I  used out-of-the-box content query web part to retrieve events from the calendar list and community column to filter the context events. I also thought of customizing itemstyle.xsl which resides in the Style Library of the site collection. To achieve this, the following steps need to be taken:

Customizing the ItemStyle XSLT file in Share Point 2013

  1. Open the site collection URL and Open the XSL Style Sheets folder to view the Itemstyle.xsl file.


  • Download the ItemStyle.xsl file to your computer. Edit that file using notepad or share point designer 2013
  • Copy the below code block and paste it above the closing </xsl:stylesheet> Here the first HTML Table row and the second HTML table row represents the column headings and the actual data respectively.


Make sure that you use this code block to output a header in XSLT:

  1. Save the file, upload the updated file to XSL Style Sheets folder in Style Library folder. Publish a Major Version to see the changes in the itemstyle.


Customizing the content query web part properties configuration in Share Point 2013

  • Open Share Point 2013 page, where you wanted to add web part and click Site Actions, and then click Edit Page. The page will displayed in edit mode as depicted in below screen.

In Editing Tools chose insert Web Part and click “Content Rollup” Category then select “Content Query” showing in parts and click Add button. Refer the below screen


  • Web part will be shown as below and customize the web part properties using “Edit Web Part” context option as directed in the below reference


  • Customize the web part properties under query section, select Show items from the following list radio button and click browse button. Select List or Library pop up will be displayed and select the “UpcomingEvents” list. Refer the below screen shot.


g10Now change the following additional settings in the web part, which are as per your requirement. Traverse to Styles section to view the properties which will look similar to the below screen shot. Make sure that you will take care of Fields to display as provided in the reference. Then click “OK” button to save the changes to the CQWP. Refer the below screen shot.




Customized content query web part in Share Point 2013




  • Guruswamy Jetti

    Guruswamy Jetti works as Module Lead with Trigent Software. He comes with over 9+ years of software development experience in Microsoft technologies, web development using SharePoint (WSS 3.0 to SharePoint Online) and Cloud based solutions such as Microsoft Azure and Office 365. He also has strong experience in integrating Microsoft CRM with SharePoint and SSRS reports.