User Documentation: HitMouse Shortcode

The hitmouse_link shortcode allows you to dynamically insert links into your WordPress posts or pages. The links are generated based on the specified id or slug and can be customized with additional attributes.


How to Use the Shortcode

You can add the hitmouse_link shortcode directly into the content of your posts or pages using the following syntax:

[hitmouse_link id="123" title="Click Me!" class="custom-class"]

Shortcode Attributes

1. id (optional)

The id specifies the unique identifier of the link in your database. If both id and slug are provided, the id takes precedence.

Example:

[hitmouse_link id="123"]

This will generate a link based on the record with ID 123.


2. slug (optional)

The slug is a URL-friendly string that uniquely identifies the link. It is used if the id attribute is not specified.

Example:

[hitmouse_link slug="my-custom-slug"]

This will generate a link using the slug my-custom-slug.


3. title (optional)

The title specifies the anchor text (visible text) of the link. If not provided, the title from the database is used.

Example:

[hitmouse_link id="123" title="Visit Our Site!"]

This will display the link with the text Visit Our Site!


4. class (optional, default: hitmouse-link)

The class adds custom CSS classes to the link for styling purposes.

Example:

[hitmouse_link id="123" class="btn btn-primary"]

This will generate a link with the classes btn btn-primary.


Output

The shortcode generates an HTML <a> tag with the attributes and values specified. Depending on the database configuration for the link, the rel and target attributes are also included.

Example 1: Using ID

[hitmouse_link id="42" title="Learn More"]

Generated Output:

<a href="https://example.com/affiliate/slug-for-id-42" class="hitmouse-link" target="_blank" rel="nofollow">Learn More</a>

Example 2: Using Slug

[hitmouse_link slug="custom-slug" title="Shop Now"]

Generated Output:

<a href="https://example.com/affiliate/custom-slug" class="hitmouse-link" target="_self">Shop Now</a>

Example 3: Custom CSS Class

[hitmouse_link id="42" class="btn btn-success"]

Generated Output:

<a href="https://example.com/affiliate/slug-for-id-42" class="btn btn-success" target="_blank" rel="nofollow sponsored">Default Title</a>

Example 4: Invalid ID or Slug

[hitmouse_link id="999"]

Generated Output:

Invalid link ID or slug.

Notes and Best Practices

  1. Enable Shortcode Usage

    Ensure that the shortcode feature is enabled in the plugin settings. If the shortcode feature is disabled, no link will be rendered.

  2. Validation and Sanitization
  3. Styling

    Customize the appearance of the links using the provided class attribute or by targeting the default class hitmouse-link in your CSS file.

  4. Fallbacks

    If neither id nor slug is valid, a fallback message (Invalid link ID or slug.) is displayed. This prevents broken or empty links from appearing.


Common Use Cases

Affiliate Links

You can use the shortcode to insert affiliate links dynamically into your content, allowing you to track and manage them through the plugin.

[hitmouse_link id="10" title="Buy Now" class="btn btn-buy"]

Promotional Campaigns

Insert links with custom slugs for promotional campaigns and track their performance.

[hitmouse_link slug="holiday-sale" title="Holiday Sale!"]

Troubleshooting

  1. Shortcode Not Rendering:
  2. Invalid Link Error:
  3. Missing Attributes:

Support

For additional help or questions about using the shortcode, visit the HitMouse Documentation or contact our support team at support@hitmouse.pro.