none
Modifying Specific text/title in Content Query Web Part

    Question

  • I'm currently using a content query web part to gather blog posts and display them on our homepage.  Each blog post is assigned a category.  What I want to do is change the color of one of the categories.  I'm guessing I need to modify the itemdisplay.xsl, but I'm wondering how to do that and specifically apply it to one of the blog post categories.  Or if there is a different way to change the text, I can give that a shot as well.

    Any help would be appreciated.

    Thank You,

    Trevor Bensen

    Thursday, February 16, 2017 4:45 PM

All replies

  • Hi Trevor Bensen,

    If there are not many results in the content query web part, you could change the color of one category by CSS code. Add the content editor web part in the page and add CSS code in the content editor web part.

    For more detailed information, refer to the article below.

    Modify Webpart Title Color, background color, Header background.

    http://anilspicyspace.blogspot.sg/2013/04/modify-webpart-title-color-background.html

    And you also could create custom template to change one category color in itemstyle.xsl. For more detailed information, refer to the article below.

    Customizing the Content Query Web Part and Item Style.

    https://www.codeproject.com/Articles/756834/Customizing-the-Content-Query-Web-Part-and-Item-St

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, February 17, 2017 7:32 AM
    Moderator
  • I looked through the articles and the first article may not work, as it doesn't specify the means to change a specific category title.  For example, one of the columns is called Blog Category and the category I want to specifically modify is called Throwback Thursday.  So, whenever this category shows up in the CQWP, I want to change the color of the text to something other that the default color.  

    I have modified one xsl file to get what I needed for another CQWP, but I'm unsure of how to properly code the xsl to specifically change and text in for the example listed above.  I suppose if there is a better way to handle this, I'm all for it.

    Thanks,

    Trevor Bensen

    Monday, February 20, 2017 9:52 PM
  • Hi Trevor Bensen,

    About CSS code, you could get the ID or class of one specific category title by F12 debug tool in IE and change the color of the title by CSS code according to the ID or class of the title.

    If you want to change the specific category title, you can add the condition before the title object to check if the title is right in xsl file.

    More reference:

    Customizing the HTML code of a Content Query Web Part.

    https://corriehaffly.wordpress.com/2010/08/07/customizing-the-html-code-of-a-content-query-web-part/

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 27, 2017 1:42 AM
    Moderator