Plugin Documentation

Plugin Shortcode


Affiliate Links plugin provides with shortcode for embedding affiliate links into the post content.


[af_link href="" rel="nofollow" target="_blank" title="Link Title" class="btn-primary"]Click Here[/af_link]


  • href=”…” – link URL (required)
  • rel=”nofollow” – add nofollow attribute (optional)
  • target=”_blank” – opens link in a new browser tab (optional)
  • title=”…” – add title attribute (optional)
  • class=”…” – add custom css class (optional)


Plugin Filters and Actions

Hooks in WordPress core, plugins and themes essentially allow you to manipulate code without editing core files. So you can change third-party plugin behaviour from your own theme or plugin and keep future updates as well.

Plugin Filters

  1. af_link_register_post_type – allows changing of the post type registration arguments.
  2. af_link_register_taxonomy – allows changing of the taxonomy registration arguments.
  3. af_link_nofollow_header – allows changing of the nofollow HTTP header before redirect is processed.
  4. af_link_target_url – allows changing of the target link URL before redirect is processed.
  5. af_link_redirect_type – allows changing of the redirection type(301, 302, 307 etc) before redirect is processed.

Plugin Actions

  • af_link_before_redirect – allows you to insert custom code before the link will be redirected to the target URL, accepted args: $post_id, $target_url, $redirect_type.

Example 1

add_filter( 'af_link_target_url', 'my_target_url_filter' );

function my_target_url_filter( $target_url ){

    $aff_id_value = 'your_value'; //some php here

    $target_url = add_query_arg( array(
    'aff_id' => $aff_id_value
    ), $target_url );

    //var_dump($target_url); die();

    return $target_url;


This example shows how you can add custom variable to the target link URL dynamically generated by PHP.

Example 2

add_action( 'af_link_before_redirect', 'my_header_action', 10, 3 );

function my_header_action( $post_id, $target_url, $redirect_type ){
    header( 'X-Custom-Header: cool!', true );

This example shows how you can add custom HTTP headers when the affiliate link is redirected to the target URL.