Hooks

Sébastien Dumont edited this page Dec 26, 2016 · 6 revisions

As of version 1.4.1 of the plugin, I have added hooks to the default template file that can be used for anything.

Action Hooks

The Loop

Use this to display content before the loop.

add_action( 'alnp_load_before_loop', 'your_function_name' );

Use this to display content after the loop.

add_action( 'alnp_load_after_loop', 'your_function_name' );

The Content

Use this to display content before the content.

add_action( 'alnp_load_before_content', 'your_function_name' );

Use this to display content before the content. This one is specific to the post format of the loading post.

add_action( 'alnp_load_before_content_type_' . $post_format, 'your_function_name' );

Use this to display content after the content.

add_action( 'alnp_load_after_content', 'your_function_name' );

Use this to display content after the content. This one is specific to the post format of the loading post.

add_action( 'alnp_load_after_content_type_' . $post_format, 'your_function_name' );

Replace $post_format with one of the supported formats. See Post Formats for a list of supported formats that you can use to display content for a specific post format.

An example of adding content to a specific post format with one of the action hooks.

function your_function_name(){
    echo '<p>This video is awesome. Share it with your friends!</p>';
}
add_action( 'alnp_load_after_content_type_video', 'your_function_name' );

So whenever a post that is formatted for video, after the content it will display whatever you want it to display.

No More Posts

Available since v1.4.8 - Once there are no more posts to load you can use this action hook.

add_action('alnp_no_more_posts', 'your_function_name');

I have also prepared a plugin that shows you an example of adding content using the hooks.