Custom Templates
You can create your own templates by adding files to your theme. Custom templates are loaded in preference to the built-in ones, so you can modify existing layouts or build entirely new ones without editing plugin files.
Creating a Custom Template
- In your active theme, create the folder
id-post-grid/templates/. - Copy any template file from the plugin’s
templates/folder into your theme folder. For example, copycard.phpto/wp-content/themes/your-theme/id-post-grid/templates/card.php. - Edit the copied file as needed. Your theme’s version takes priority over the plugin’s.
Available Variables
Every template file receives the following PHP variables, set by the plugin before the template is included:
$taxonomy— The taxonomy slug used for filtering (e.g.,category).$show_image— Boolean, whether to display the featured image.$image_size— WordPress image size string (e.g.,medium_large).$show_title— Boolean, whether to display the post title.$show_excerpt— Boolean, whether to display the excerpt.$excerpt_length— Integer, number of words in the excerpt.$show_date— Boolean, whether to display the post date.$show_category— Boolean, whether to display the category label.$show_read_more— Boolean, whether to display the read more link.$read_more_text— String, the text for the read more link.$read_more_style— String, eithertext(link) orbutton.$is_featured— Boolean, true if this item is the featured post.
Template Structure
Each template should output a single <article> element with the class id-post-grid-item. When $is_featured is true, add the class id-post-grid-item-featured. The plugin’s CSS relies on these class names for layout and styling.
Building a New Template from Scratch
To create an entirely new template (rather than modifying an existing one), add a PHP file with any name to your theme’s id-post-grid/templates/ folder. Then reference it by its filename (without the .php extension) in the template shortcode attribute:
[id_post_grid template="my-custom-layout"]
This loads /wp-content/themes/your-theme/id-post-grid/templates/my-custom-layout.php.
