Change Default Attributes

If you find yourself typing the same parameters over and over, you can save time by changing the default attributes. These can always be overridden by specifying new attributes on an individual shortcode.

For instance, let’s say you always list 20 posts with excerpts:

[display-posts include_excerpt="true" posts_per_page="20"]

We can use the following to set these as the default:

This code snippet goes in a core functionality plugin or Code Snippets.

Now we can get the same result without having to specify the attribute:


And if we want to use different settings on a page, we can use the parameters to override the default:

[display-posts include_excerpt="false" posts_per_page="5"]

Filters used:

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.