Shortcodes
Reference for the shortcodes the Companion plugin registers, with what each one prints and the attributes it accepts.
Updated
On this page
A shortcode is a short code in square brackets that the Companion replaces with a form, a grid or a button when the page is shown. To add one, add a Shortcode block to the page in the editor and type the shortcode in it.
| Shortcode | Plugin | What it shows |
|---|---|---|
[itdcompanion_contact_form] |
Companion (free and Pro) | A Contact Form 7 form, or an email button |
[itdcompanion_projects] |
Companion Pro | The grid of your projects |
[itdcompanion_featured_properties] |
Companion Pro | Your newest property listings |
[itdcompanion_featured_vehicles] |
Companion Pro | Your featured vehicles |
[itdcompanion_finance_calculator] |
Companion Pro | A monthly payment calculator |
The old itd_ shortcodes
These are the names from Companion 1.5.0 on. Before that, the shortcodes started with itd_ instead of itdcompanion_: [itd_contact_form], [itd_projects], [itd_featured_properties], [itd_featured_vehicles] and [itd_finance_calculator]. The old itd_ shortcodes still work with Companion Pro: they take the same attributes and show exactly the same thing, so pages made with them, including the pages of the Pro starter sites you imported before, need no change. Use the new names in new pages. The free Companion knows only the new name, [itdcompanion_contact_form].
[itdcompanion_contact_form]
Shows a contact form made with the free Contact Form 7 plugin. The Pro starter sites put it on their contact page.
[itdcompanion_contact_form]
When Contact Form 7 is active, the shortcode shows your oldest Contact Form 7 form, the first one created on the site. It leaves out every form that a starter site’s import created for its own page: the reservation form and the test drive form, both described below.
The shortcode checks for Contact Form 7 every time the page is shown. If you deactivate Contact Form 7 later, the page shows the button described in Without Contact Form 7, not a broken shortcode.
While the Companion is active, Contact Form 7 loads its scripts and styles only where a form can appear: on a page or post whose content contains [itdcompanion_contact_form], Contact Form 7’s own shortcode or its block; on every page when a widget in one of the theme’s widget areas contains one of them; and, with Companion Pro, on a property listing’s page and on a vehicle’s page. Other pages load faster without them.
Attributes
form: set it toreservationto show the “Table reservation” form, or totest-driveto show the “Test drive request” form, instead of your first form. Empty by default. Any other value works like no attribute.
[itdcompanion_contact_form form="reservation"]
[itdcompanion_contact_form form="test-drive"]
The Restaurant starter site creates the “Table reservation” form when you import it with Contact Form 7 active. See The reservation form. The CarDealer starter site does the same for the “Test drive request” form. See The test drive form.
Without Contact Form 7
When Contact Form 7 is not active, or it has no form the shortcode can show, the shortcode shows a button instead: Email Us, Email Your Reservation with form="reservation", or Email Your Test Drive Request with form="test-drive". The button opens an email to the Administration Email Address of Settings › General. The reservation button also fills in the subject “Table reservation”, and the test drive button the subject “Test drive request”. In the page source the address is encoded, so that the programs that collect email addresses from web pages do not find it.
If the site has no valid administration email address, the shortcode shows nothing to visitors. Administrators see a line instead: “Only administrators see this: the contact button is hidden because the site has no valid email address. Install Contact Form 7, or set the Administration Email Address in Settings › General.”
To write to a different address, a developer can use the itdcompanion_contact_mailto filter, for example in the functions.php file of a child theme:
add_filter( 'itdcompanion_contact_mailto', function () {
return 'mailto:hello@your-business.example';
} );
Replace the address with your own, and keep the mailto: at the start: with any other kind of address, the button reloads the page instead of opening an email.
[itdcompanion_projects]
Shows the grid of your projects, newest first. It needs Companion Pro, with the Projects module switched on: on the Modules tab, the Projects (portfolio) panel has a Switch on projects button. A starter site that has projects switches the module on when you import it. See Companion Pro.
[itdcompanion_projects]
Each card shows the project’s featured image, its first category, its title, a short description, and its client and year. The short description is the project’s excerpt, or the first words of its content when it has no excerpt. A card leads to the project’s Website when you fill it in, in a new tab. Otherwise it leads to the project’s own page.
When there are more projects than one page of the grid shows, a Load more link adds the next ones. When no project is published yet, the grid says “No projects published yet.”
Attributes
per_page: how many projects the grid shows at first, and how many each Load more adds. A number from 1 to 48; the default is12. A number outside 1 to 48 counts as the closest limit.filter: set it to1to show a bar of categories above the grid: All, then one link for each project category that has published projects. Off by default.category: the slug of a project category, to show only the projects of that category. Empty by default.
Examples:
[itdcompanion_projects per_page="9" filter="1"]
[itdcompanion_projects category="branding" filter="1"]
In the second example, branding stands for the slug of one of your project categories. You find the slugs in Projects › Project Categories.
With both category and filter, All in the bar shows every project of that category, and the other links narrow it down further. The bar still lists every project category that has published projects, so a link can lead to a category with no projects inside the one you set: it then shows “No projects published yet.” If no project category with published projects has that slug, the grid shows all your projects.
The category bar and Load more are ordinary links, so they work without JavaScript, and each view of the grid has its own address that you can share.
When the Projects module is switched off, the shortcode shows nothing. The free Companion does not have this shortcode, so WordPress shows it on the page as you typed it.
[itdcompanion_featured_properties]
Shows your newest property listings as cards. It needs Companion Pro, with the property listings switched on: on the Modules tab, the Property listings panel has a Switch on property listings button. The Real Estate starter site switches them on when you import it.
[itdcompanion_featured_properties count="3"]
count: how many listings to show. A number from 1 to 12; the default is3. A number outside 1 to 12 counts as the closest limit.
When no listing is published yet, it says “No properties published yet.” When property listings are switched off, the shortcode shows nothing. The free Companion does not have this shortcode, so WordPress shows it on the page as you typed it.
[itdcompanion_featured_vehicles]
Shows your featured vehicles as cards. It needs Companion Pro, with the vehicle inventory switched on: on the Modules tab, the Vehicle inventory panel has a Switch on vehicle inventory button. The CarDealer starter site switches it on when you import it.
[itdcompanion_featured_vehicles count="4"]
count: how many vehicles to show. A number from 1 to 12; the default is4. A number outside 1 to 12 counts as the closest limit.
It shows the vehicles whose Featured box is set to Yes, newest first, and fills what is left with your newest other vehicles. When no vehicle is published yet, it says “No vehicles published yet.” When the vehicle inventory is switched off, the shortcode shows nothing. The free Companion does not have this shortcode, so WordPress shows it on the page as you typed it.
[itdcompanion_finance_calculator]
Shows a calculator of the monthly payment. It needs Companion Pro, with the vehicle inventory switched on, like [itdcompanion_featured_vehicles].
[itdcompanion_finance_calculator]
The visitor types a vehicle price, chooses a deposit from 10% to 50% and a term of 24, 36, 48 or 60 months, and clicks Calculate. The result is the monthly payment, to the cent, with the amount of credit and the deposit. It uses the representative example’s fixed rate, and prints that example under the result. It works without JavaScript, and with it the result updates as the visitor chooses. See Vehicles.
price: the price of one vehicle, as a number. The visitor then cannot change the price, and the calculator shows it as a fixed line. Empty by default, so that the visitor types a price.compact: with aprice, set it to1to lay the calculator out in one row, as on a vehicle’s page. It has no effect without aprice.
When the vehicle inventory is switched off, the shortcode shows nothing. The free Companion does not have this shortcode, so WordPress shows it on the page as you typed it.
