Theming Exchange - Hooking into Exchange Templates

From iThemes Codex
Jump to: navigation, search

Each Exchange template contains a set of action hooks for theme and add-on developers to use. The best way to find the names of these hooks is looking within a template file, but this page will try to explain the basic concept of these action hooks and how to use them.

When creating an add-on for Exchange, one thing a developer needs is a way to add the add-ons items to the different pages of Exchange. The best way to do this is with action hooks.

do_action( 'action_tag_name' );


Let's say you wanted to add a notification (perhaps about an upcoming sale) to the cart, just above the cart items, but did not want to copy over the entire cart items template (templates/content-cart/elements/items.php). This could be accomplished using the follow hook:

do_action( 'it_exchange_content_cart_before_items' );

Here is what you would add.

function custom_sale_notification_before_cart_items() {
		<div class="notification">
			<p>There is an upcoming sale!</p>
add_action( 'it_exchange_content_cart_before_items', 'custom_sale_notification_before_cart_items' );

There are (literally) hundreds of action hooks to use.

Dig into the templates (ithemes-exchange/lib/templates) and look for the do_action reference to find the one you need.

See also

← Back to Exchange Codex Home