WP Better Attachments Shortcodes

Below, you’ll find a detailed guide on how to add the WP Better Attachments Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP Better Attachments Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the WP Better Attachments Plugin and the shortcodes it provides:

Plugin Icon
WP Better Attachments

"WP Better Attachments is a superior WordPress plugin that simplifies and enhances your handling and management of attachments, offering a streamlined user experience."

★★★★★ (28) Active Installs: 2000+ Tested with: 4.2.36 PHP Version: false
Included Shortcodes:
  • [wpba-attachment-list]
  • [wpba-flexslider]

WP Better Attachments [wpba-attachment-list] Shortcode

The WP-Better-Attachments plugin shortcode ‘wpba-attachment-list’ is designed to generate a list of attachments. It uses the function ‘wpba_attachment_list_shortcode’ to ensure the attributes are properly formatted. It then calls the ‘build_attachment_list’ function from the global ‘$wpba_frontend’ object. This function constructs the attachment list based on the given attributes.

Shortcode: [wpba-attachment-list]

Examples and Usage

Basic example – A simple usage of the ‘wpba-attachment-list’ shortcode without any parameters. This will display a list of attachments related to the current post.

[wpba-attachment-list /]

Advanced examples

1. Using the shortcode with a ‘post_id’ parameter. This will display a list of attachments related to the specified post ID. Replace ‘123’ with the ID of the post you want to display attachments for.

[wpba-attachment-list post_id="123" /]

2. Using the shortcode with ‘post_id’ and ‘limit’ parameters. This will display a specific number of attachments related to the specified post ID. Replace ‘123’ with the ID of the post you want to display attachments for, and ‘5’ with the number of attachments you want to display.

[wpba-attachment-list post_id="123" limit="5" /]

3. Using the shortcode with ‘post_id’, ‘limit’, and ‘orderby’ parameters. This will display a specific number of attachments related to the specified post ID, ordered by the specified parameter. Replace ‘123’ with the ID of the post you want to display attachments for, ‘5’ with the number of attachments you want to display, and ‘title’ with the parameter you want to order the attachments by.

[wpba-attachment-list post_id="123" limit="5" orderby="title" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpba-attachment-list] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpba-attachment-list','wpba_attachment_list_shortcode' );

Shortcode PHP function:

function wpba_attachment_list_shortcode( $atts )
{
	// Make sure atts is an array
	$atts = ( gettype( $atts ) != 'array' ) ? array() : $atts;
	global $wpba_frontend;
	return $wpba_frontend->build_attachment_list( $atts );
}

Code file location:

wp-better-attachments/wp-better-attachments/inc/shortcodes.inc.php

WP Better Attachments [wpba-flexslider] Shortcode

The WP-Better-Attachments plugin shortcode, ‘wpba-flexslider’, facilitates a flexible, responsive slideshow. It starts by ensuring ‘atts’ is an array. It then registers and enqueues the flexslider script, and finally builds the flexslider with the given attributes.

Shortcode: [wpba-flexslider]

Examples and Usage

Basic Example – The simplest way to use the wpba-flexslider shortcode is to call it without any parameters or attributes. This will display a default flexslider on your page.

[wpba-flexslider]

Advanced Examples

You can customize the wpba-flexslider shortcode by using various parameters or attributes. Here are a few examples:

1. Specify the ID of the flexslider you want to display. This is useful if you have multiple flexsliders and want to display a specific one.

[wpba-flexslider id="123"]

2. Adjust the speed of the flexslider. This attribute allows you to control how fast the slides change. The speed is measured in milliseconds.

[wpba-flexslider speed="5000"]

3. Enable or disable automatic sliding. By default, the slides will automatically change after a certain amount of time. If you want to disable this feature, you can use the ‘auto’ attribute.

[wpba-flexslider auto="false"]

Please note that the actual parameters or attributes available may vary depending on the version of the wp-better-attachments plugin you are using. Always refer to the plugin’s documentation for the most accurate information.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpba-flexslider] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpba-flexslider','wpba_flexslider_shortcode' );

Shortcode PHP function:

function wpba_flexslider_shortcode( $atts ) {
	// Make sure atts is an array
	$atts = ( gettype( $atts ) != 'array' ) ? array() : $atts;

	global $wpba_frontend;

	$wpba_frontend->register_flexslider();
	wp_enqueue_script( 'wpba_front_end_styles' );

	return $wpba_frontend->build_flexslider( $atts );
}

Code file location:

wp-better-attachments/wp-better-attachments/inc/shortcodes.inc.php

Conclusion

Now that you’ve learned how to embed the WP Better Attachments Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *