Type Name: Action

appthemes_after_post

This action hook executes in the loop-[post_type].php file and loads at the end of the_content() but before the loop endwhile runs.

appthemes_after_post();

Example: Share Link

You can use this hook to add meta data to a post, like a share link for social media sites.

<?php
function insert_share_link() { 
    echo '<div class="share-link">' . __( 'Share this link with your friends!', 'appthemes' ) . '<input type="text" value="' . esc_attr( get_permalink() ) . '">';
} 
add_action( 'appthemes_after_post', 'insert_share_link' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_after_post() is located in loop-[post_type].php.

appthemes_after_post_content

This action hook executes in the loop-[post_type].php file and loads right after the_content() is run.

appthemes_after_post_content();

Example: Share Link

You can use this hook to add meta data to a post, like a share link for social media sites.

<?php
function insert_share_link() { 
    echo '<div class="share-link">' . __( 'Share this link with your friends!', 'appthemes' ) . '<input type="text" value="' . esc_attr( get_permalink() ) . '">';
} 
add_action( 'appthemes_after_post_content', 'insert_share_link' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_after_post_content() is located in loop-[post_type].php.

appthemes_before_post_content

This action hook executes in the loop-[post_type].php file and loads right before the_content() is run.

appthemes_before_post_content();

Example: Advertisment

This code would display an AppThemes banner advertisement above the content of every page.

<?php
function insert_banner_ad_before_page() { 
    echo '<a href="http://www.appthemes.com"><img src="http://www.appthemes.com/ads/at-468x60a.gif"></a>';
}
add_action( 'appthemes_before_post_content', 'insert_banner_ad_before_page' ); 
?>

Example: Adding an Announcement Bar

You can insert special information for the user about a sale, upcoming event, or other notification here.

<?php
function sale_annoucement() { 
    echo '<div class="annoucement">' . __('Come back July 5th for 10% off everything!', 'appthemes') . '</div>';
}
add_action( 'appthemes_before_post_content', 'sale_annoucement' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_before_post_content() is located in loop-[post_type].php.

appthemes_after_post_title

Runs in the loop-[post_type].php and loads after the custom post type title (usually in an h1 or h2 tag) is displayed on the page.

appthemes_after_post_title();

Example: Print Date

You can use this space to print meta data, like the date

<?php
function insert_date() { 
    echo '<p>' . get_the_date() . '</p>';
}
add_action( 'appthemes_after_post_title', 'insert_date' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_after_post_title() is located in loop-[post_type].php.

appthemes_before_post_title

Runs in the loop-[post_type].php and loads before the custom post type title is displayed on the page.

appthemes_before_post_title();

Example: Advertisment

This code would display an AppThemes banner advertisement above the content of every page.

<?php
function insert_banner_ad_before_page() { 
    echo '<a href="http://www.appthemes.com"><img src="http://www.appthemes.com/ads/at-468x60a.gif"></a>';
}
add_action( 'appthemes_before_page_content', 'insert_banner_ad_before_page' ); 
?>

Example: Adding an Announcement Bar

You can insert special information for the user about a sale, upcoming event, or other notification here.

<?php
function sale_annoucement() { 
    echo '<div class="annoucement">' . __('Come back July 5th for 10% off everything!', 'appthemes') . '</div>';
}
add_action( 'appthemes_before_page_content', 'sale_annoucement' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_before_post_title() is located in loop-[post_type].php.

appthemes_before_post

Executes in the loop-[post_type].php file and runs after have_posts() within the loop whenever any custom post type content is loaded.

appthemes_before_post();

Example: Advertisment

This code would display an AppThemes banner advertisement above the content of every page.

<?php
function insert_banner_ad_before_page() { 
    echo '<a href="http://www.appthemes.com"><img src="http://www.appthemes.com/ads/at-468x60a.gif"></a>';
}
add_action( 'appthemes_before_post', 'insert_banner_ad_before_page' ); 
?>

Example: Adding an Announcement Bar

You can insert special information for the user about a sale, upcoming event, or other notification here.

<?php
function sale_annoucement() { 
    echo '<div class="annoucement">' . __('Come back July 5th for 10% off everything!', 'appthemes') . '</div>';
}
add_action( 'appthemes_before_post', 'sale_annoucement' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_before_post() is located in loop-[post_type].php.

appthemes_before_loop

Runs in the loop-[post_type].php file and runs before the have_posts() loop whenever any custom post type content (i.e. ad listing, coupon, job listing, etc) is loaded.

appthemes_before_loop();

Example: Advertisment

This code would display an AppThemes banner advertisement above the content of every page.

function insert_banner_ad_before_page() { 
    echo '<a href="http://www.appthemes.com"><img src="http://www.appthemes.com/ads/at-468x60a.gif"></a>';
}
add_action( 'appthemes_before_loop', 'insert_banner_ad_before_page' );

Example: Advertisment on category page

This code would display an AppThemes banner advertisement above the content of category page.

function insert_banner_ad_on_category_page() { 
  if(is_tax(APP_TAX_CAT))
    echo '<a href="http://www.appthemes.com"><img src="http://www.appthemes.com/ads/at-468x60a.gif"></a>';
}
add_action( 'appthemes_before_loop', 'insert_banner_ad_on_category_page' );

Example: Adding an Announcement Bar

You can insert special information for the user about a sale, upcoming event, or other notification here.

function sale_annoucement() { 
    echo '<div class="annoucement">' . __('Come back July 5th for 10% off everything!', 'appthemes') . '</div>';
}
add_action( 'appthemes_before_loop', 'sale_annoucement' );

Changelog

  • since 1.1

Source File

appthemes_before_loop() is located in loop-[post_type].php.

appthemes_after_comments_form

This function executes in the comments-[post_type].php file and loads after the custom post type comments respond form.

appthemes_after_comments_form();

Example: Legal Disclaimers

You can use this hook to add things like legal disclaimers or other information your readers should know after commenting.

<?php
function insert_comments_disclaimer() { 
    echo '<div class="disclaimer">' . __( 'Comments will be moderated and approved upon author\'s discretion.' ) . '</div>';
}
add_action( 'appthemes_after_comments_form', 'insert_comments_disclaimer' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_after_comments_form() is located in comments-[post_type].php.

appthemes_comments_form

This function executes in the comments-[post_type].php file and loads the custom post type comments respond form. This function can be overridden and replaced with your own comments form.

Usage

This hook provides no parameters. You use this hook by having your function echo output to the browser, or by having it perform background tasks. Your functions shouldn’t return, and shouldn’t take any parameters.

add_action( 'appthemes_comments_form', 'your_function' );

Example

<?php
// let's remove default ClassiPress blog comments form
remove_action( 'appthemes_comments_form', 'cp_main_comment_form' );
 
// use this comments form instead for blog posts
function insert_your_own_comments_form() { 
?>
    <div id="respond">
 
        <h2 class="dotted"><?php comment_form_title( __('Leave a Reply','appthemes'), __('Leave a Reply to %s','appthemes') ); ?></h2>
 
        <div class="cancel-comment-reply">
            <small><?php cancel_comment_reply_link(); ?></small>
        </div>
 
        <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
 
            <p><?php printf( __("You must be <a href='%s'>logged in</a> to post a comment.", 'appthemes'), get_option('siteurl').'/wp-login.php?redirect_to='.urlencode( get_permalink() ) ); ?></p>
 
        <?php else : ?>
 
            <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" class="commentform">
 
                <fieldset class="form-comments">
 
                <?php if ( is_user_logged_in() ) : global $user_identity; ?>
 
                    <p><?php _e('Logged in as','appthemes'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(); ?>" title="<?php _e('Logout of this account','appthemes'); ?>"><?php _e('Logout','appthemes'); ?> &raquo;</a></p>
 
                <?php else : ?>
 
                    <?php 
                        $commenter = wp_get_current_commenter();
                        $req = get_option( 'require_name_email' ); 
                    ?>
 
                    <p class="comments">
                        <label for="author"><?php _e('Name','appthemes'); ?> <?php if ( $req ) _e('(required)','appthemes'); ?></label>
                        <input type="text" name="author" id="author" class="text required" value="<?php echo esc_attr( $commenter['comment_author'] ); ?>" size="22" tabindex="1" />
                    </p>
 
                    <div class="clr"></div>
 
                    <p class="comments">
                        <label for="email"><?php _e('Email (will not be visible)','appthemes'); ?> <?php if ( $req ) _e('(required)','appthemes'); ?></label>
                        <input type="text" name="email" id="email" class="text required email" value="<?php echo esc_attr(  $commenter['comment_author_email'] ); ?>" size="22" tabindex="2" />                                
                    </p>
 
                    <div class="clr"></div>
 
                   <p class="comments">
                        <label for="url"><?php _e('Website','appthemes'); ?></label>
                        <input type="text" name="url" id="url" class="text" value="<?php echo esc_attr( $commenter['comment_author_url'] ); ?>" size="22" tabindex="3" />
                    </p>
 
                   <div class="clr"></div>
 
                <?php endif; ?>
 
                <p class="comments-box">
                    <textarea name="comment" rows="" cols="" id="comment" class="required" tabindex="4"></textarea>
                </p>
 
                <div class="clr"></div>
 
                <p class="comments">
                    <input name="submit" type="submit" id="submit" tabindex="5" class="btn_orange" value="<?php _e('Leave a Reply','appthemes'); ?>" />
                    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
                </p>
 
                <?php comment_id_fields(); ?>
                <?php do_action( 'comment_form', $post->ID ); ?>
 
                 </fieldset>
 
            </form>
 
        <?php endif; // if logged in ?>
 
        <div class="clr"></div>
 
    </div> <!-- /respond -->
 
<?php
}
add_action( 'appthemes_comments_form', 'insert_your_own_comments_form' ); 
?>

Changelog

  • since 1.1

Source File

appthemes_comments_form() is located in comments-[post_type].php.

appthemes_add_submenu_page_content

This action hook is triggered within the WordPress admin theme option pages. It provides no parameters but must be used in conjunction with theappthemes_add_submenu_page function in order to work properly.

appthemes_add_submenu_page_content();

Usage

This example sets up your new admin theme page with one drop-down option value. You will need to paste this code within your functions.php theme file. For a full example, see appthemes_add_submenu_page function.

<?php
 
// create the actual page and new field(s)
function my_custom_appthemes_admin_page_content() { 
	global $app_abbr;
 
$my_options = array( 
		array(  'type' => 'tab',
			'tabname' => __('Tab Title', 'appthemes')),
 
		array(	'name' => __('Section Title', 'appthemes'),
			'type' => 'title',
			'desc' => '',
			'id' => ''),
 
		array(  'name' => __('Option Name','appthemes'),
			'desc' => '',
			'tip' => __('Enter your tooltip text here.','appthemes'),
			'id' => $app_abbr.'_custom_field_name',
			'css' => 'min-width:100px;',
			'std' => 'yes',
			'vis' => '',
			'req' => '',
			'js' => '',
			'min' => '',
			'type' => 'select',
			'options' => array(  'yes' => __('Yes', 'appthemes'),
					     'no'  => __('No', 'appthemes'))),
 
		array(  'type' => 'tabend'),						 
);
 
// update and save the options in the WordPress database on form submit
appthemes_update_options( $my_options );
?>
 
	<div>
        <div id="icon-tools"><br/></div>
        <h2><?php _e('Testing','cp') ?></h2>
 
        <form method="post" id="mainform" action="">
            <p><input name="save" type="submit" value="<?php _e('Save changes','appthemes') ?>" /></p>            
 
	<?php appthemes_admin_fields($options_testing); ?>
 
            <p><input name="save" type="submit" value="<?php _e('Save changes','appthemes') ?>" /></p>
            <input name="submitted" type="hidden" value="yes" />
        </form>
    </div>
 
<?php
}
add_action('appthemes_add_submenu_page_content', 'my_custom_appthemes_admin_page_content', 10);
 
?>

Changelog

  • since appthemes-functions.php version 1.2

Source File

appthemes_add_submenu_page() is located in includes/admin/admin-options.php.