Developer API

Details of the hooks and filters that are available to developers

metaslider_capability

Description

Use this filter to modify the user capability required to use MetaSlider. The default capability is ‘edit_others_posts’.

Parameters

$capability

(string) (required) User role capability

Examples

Change the capability required to use MetaSlider

You can change the required capability to any default capability included in WordPress.

In the example below we’ve used the User Role Editor plugin to create a custom capability (called ‘metaslider_use’).

metaslider_post_feed_args

Description

Use this filter to modify the query arguments used to extract posts in a Post Feed slide.

Parameters

$args

(array) (required) WP_Query arguments as defined by the slide settings

$slide

(object) (required) Current slide data

$slider_settings

(array) (required) Current slider settings

$slide_settings

(array) (required) Current slide settings

Examples

The following code samples should be added to your theme’s functions.php file.

Display all posts tagged to the current category

Use this code to override the taxonomy restrictions defined in the slide settings, and instead extract all posts which are tagged to the current category. With this code in place you can create a single slideshow and add the Template Include to your category.php template. The slideshow will automatically show posts that are tagged to the current category.

 Display Sticky Posts only

 

metaslider_hoplink

Description

Use this filter to modify the URL used in the “Go Pro” links throughout MetaSlider. This is for use by theme developers who have signed up as an affiliate.

Parameters

$link

(string) (required) The URL used to direct users to www.metaslider.com from all “Go Pro” links within the MetaSlider interface.

Examples

Use Affiliate URL

metaslider_default_parameters

Description

Use this filter to modify the default slideshow settings. Theme developers may wish to use this to automatically set a ‘recommended’ slideshow size.

Note: this will only apply to the first ever slideshow created in MetaSlider. Subsequent slideshows are given a copy of the settings for the last edited slideshow.

Parameters

$params

(array) (required) Default slideshow settings

Examples

Change Default Slideshow Size

metaslider_resized_image_url

Description

Usethis filter to modify the slide image URL used by MetaSlider. For example, it could be used to change the full image URL to a relative image URL.

Parameters

$cropped_url

(string) (required) The URL to the cropped/resized image (e.g. http://[…]/image-150x150.jpg)

$orig_url

(string) (required) The URL to the full size image (e.g.  http://[…]/image.jpg)

Examples

Protocol Relative URLs

The example below will remove the “http:” portion of the image URL, making it into a “protocol relative URL”. This will allow the image to be loaded over the same protocol as the page itself (ideal for https pages).

Disable Cropping

The example below effectively disables cropping by returning the original, full size image URL for each slide.

metaslider_image_{$type}_slider_markup

Description

This filter allows you to modify the complete slide HTML generated by MetaSlider.

{type} can be flex, coin, responsive or nivo.

Parameters

$html

(string) (required) HTML markup for the complete slide

$slide

(array) (required) Slide data

$settings

(array) (required) Slideshow settings

Examples

Append custom HTML to each slide

metaslider_{type}_slider_image_attributes

Description

Use this filter to modify or add attributes to each slide image tag.

{type} can be flex, coin, responsive or nivo.

Parameters

$attributes

(array) (required) Default image attributes (eg width, height, src).

$slide

(array) (required) Slide data

$slider_id

(int) (required) Slideshow ID

Examples

Add rel attribute

This example will add a ‘rel’ attribute of ‘lightbox’ to each slide in the slideshow. Eg,  <img width='x' height='x' src='x' rel='lightbox' />

metaslider_{type}_slider_anchor_attributes

Description

Use this filter to modify or add attributes to each slide anchor (link) tag.

{type} can be flex, coin, responsive or nivo.

Parameters

$attributes

(array) (required) Default anchor attributes (eg url, target etc).

$slide

(array) (required) Slide data

$slider_id

(int) (required) Slideshow ID

Examples

This example will automatically link each slide to it’s full image URL. {type} can be flex, coin, responsive or nivo.

metaslider_{type}_slider_javascript

Use this filter to add javascript below (after) the slider JavaScript call. {type} can be flex, coin, responsive or nivo.

metaslider_{type}_slider_javascript_before

Use this filter to add javascript before the slider JavaScript call. {type} can be flex, coin, responsive or nivo.

metaslider_{type}_slider_parameters

Description

Use this filter to modify the JavaScript properties used to initiate the slideshow.

MetaSlider exposes most of each slideshows options in the slideshow settings, but there are some specialist options that are offered by each slideshow library that you cannot change through the MetaSlider interface. This filter allows you to change existing properties or add new ones.

For a full list of available properties, see Flex Slider Properties, Nivo Slider Properties (scroll down to ‘Play with settings’), Coin Slider Properties (scroll down to ‘List of all options’), Responsive Slides Properties (scroll down to ‘Options you can customise’)

Important:

  • To create/alter an integer property value, omit quotes
  • To create/alter a string property value, use single or double quotes
  • To create or add to a function, assign the value to an array (see first example)

{type} can be flex, coin, responsive or nivo.

Parameters

$options

(array) (required) Slideshow properties

$slider_id

(array) (required) Slideshow ID

$settings

(int) (required) Slideshow settings

Examples

Altering Flex Slider Properties

The above code will result in the following output: