Theming Exchange - Filtering Exchange Template Part Elements

From IThemes Codex
Revision as of 07:17, September 24, 2013 by Kopepasah (Talk | contribs)
Jump to: navigation, search

In Most of the tempalte parts for exchange you will notice a function: it_exchange_get_template_part_elements().

This function gives both theme and addons developers the power to alter what element(s) each template part loops through by providing a filter based on the context and detail that the function calls for.

Function Call

	it_exchange_get_template_part_elements( $context, $detail, $parts )

Filter Tag


For example, in lib/templates/content-cart/loops/actions.php the function calls for the context 'content_cart' and the detail 'actions'. Our filter tag for modifying this is as follows.


This filter will return the $parts (which can be modified).


For the filter above (it_exchange_get_content_cart_actions_elements), let's say we want to remove the apply-coupon action. We can do this by filtering the elements of that array like so:

function custom_exchange_filter_content_cart_actions( $parts ) {
	foreach ( $parts as $key => $part ) {
		if ( 'apply-coupon' == $part ) {
			unset( $parts[$key] );
	return $parts;
add_action( 'it_exchange_get_content_cart_actions_elements', 'custom_exchange_filter_content_cart_actions' );

Please note that these filters are for advanced users and should be used with caution.

Personal tools
iThemes Codex
Codex Navigation