CP Library Templates

Creating Custom Shortcodes

Starting in 1.3.0, you can create custom message and series layouts that can be saved as shortcodes and used anywhere on your site. Powered by the Gutenberg editor, you have very fine-tuned control over design and styling. To create a template, find the Templates menu item in the CP Sermons submenu and click “Add New” in the top left.

Creating your first template

When creating a template, you will be presented with a blank Gutenberg page, ready for editing. To add your first block, type a forward slash (/) into the visible text field. Start typing the words “CP Sermons”, and click on the block that appears at the top of the list. Another way to do the same thing is to click on the plus icon in the top left of the editing window and browse the available blocks in the sidebar. You can drag these blocks anywhere on the page.

Using a forward slash (/)
Using the block finder

CP Sermons Sermons/Series block

The CP Sermons Sermons/Series block is the basis for all message and series layouts. It contains the controls for filtering messages or series and some basic layout options. It displays a list of inner post templates, and any changes made to one will automatically update all others in the list. If you’ve used Gutenberg, you will see it behaves identically to the native query loop block with some added enhancements specific to CP Sermons’ content.

When first inserting the block onto a page, you will have the option to choose a template or start blank. CP Sermons provides several predefined layouts, making it easier for you to get started. If you have not worked with Gutenberg, we recommend using an existing pattern when getting started so that you can see the various settings used to build that layout.

In order to view the controls for the Sermons/Series block, you will need to have it focused in your editor. A selected block will have its corresponding controls both in a toolbar above the block or in the sidebar on the right side of the screen. If you’re not seeing the sidebar, click on the icon to the right of the Publish button to open it.

When trying to edit a block that contains nested blocks, it may be tricky to select it directly. To get to a parent block of the currently selected block, click the icon on the far left of the toolbar that appears above a selected block. This will select the parent block. You can do this multiple times until you have found the block you want. Another method is to open the document overview, accessed by clicking the three horizontal lines in the top left of the screen. This opens a list-style view of your page content.

Using the Document Overview
Selecting the parent block
Controls Overview

In the block toolbar, there are several quick-access options available, as seen in the screenshot below. You can control the sermon count, the start offset, and the number of pages (this only applies when using pagination.) You can switch between a grid or list view with the corresponding icons in the toolbar. When in grid view, you will have an additional control for the number of columns in the sidebar.

You have to option to display either sermons or series as the content type. Take note that when switching the post type, any blocks that aren’t compatible with the new post type will be removed (for example, the sermon speaker does not work inside a series block.)

When displaying sermons, you also have the option to show or hide upcoming sermons, classified by whether they have any attached audio or video files/URLs.

The Single Item option is for if you would like to display a single sermon or series by name. The other filtering options, such as item count and order, will be hidden in place of a search box where you can find and select a single item to display. If you want to display only the latest item, you should set the item count to 1 and order by newest.

Inner template blocks

There are several custom Gutenberg blocks for use in an inner template. To access them look for the CP Library block category in the block sidebar.

  • Item Date – A block for displaying the date a sermon or series was published.
  • Item Modified Date – Displays the date the sermon or series was last updated.
  • Item Description – Displays the post excerpt. You can customize the number of visible words as well as the read more link.
  • Item Graphic – The graphic set for a sermon or series. It will use the fallback provided in your site’s global CP Sermons settings if none is set. This block also allows you to add inner blocks.
  • Item Title – This displays the sermon or series title, and it has all the normal Gutenberg title controls.
  • Sermon Actions – This adds buttons for playing the sermon audio and video, if applicable. It only works when used on a sermon list.
  • Sermon Scripture – Displays the specified scripture for a sermon. When used on a series block it displays all the scriptures used in the sermons included in the series.
  • Sermon Series – Displays any series a sermon belongs to. As you may guess, this does not work on series lists.
  • Sermon Speaker – This block displays the sermon speaker, and works only on sermon lists.
  • Sermon Topics – Lists any assigned topics and is only applicable on sermon lists.

Displaying your template

After publishing a layout, you can display it anywhere on your site. CP Sermons has provided blocks for several of the major page builders (Elementor, Beaver Builder, Divi, and Gutenberg), which allow you to select from your completed templates and display them on the page. In any of these builders, you can search for “CP Sermons Template” and add the block to the page, which will give you a dropdown of the published templates to choose from.

CP Sermons also provides a shortcode for displaying a template. To display a template by ID, add [cpl_template id=<template ID>] anywhere on a page. You also can copy the shortcode from the sidebar on the template edit page.

Was this article helpful?

Related Articles

Scroll to Top