Below, you’ll find a detailed guide on how to add the Logo Carousel Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Logo Carousel Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Logo Carousel Plugin and the shortcodes it provides:
"Logo Carousel – Logo Slider, Logo Showcase, and Clients Logo Gallery is a dynamic WordPress plugin designed to display and slide your company logos, clients' logos, sponsors' logos, and partners' logos easily and effectively."
- [logocarousel]
Logo Carousel [logocarousel] Shortcode
The Logo Carousel Free plugin shortcode is designed to render a logo carousel on your website. It checks the post type and status, and if valid, retrieves logo data and initiates the carousel. It enqueues necessary styles and scripts, loads dynamic styles, and updates options if needed. It also retrieves and displays the main section title, providing a seamless user experience.
Shortcode: [logocarousel]
Parameters
Here is a list of all possible logocarousel shortcode parameters and attributes:
id
– Unique ID assigned to each logo carousel
Examples and Usage
Basic example – A simple way to use the logo carousel shortcode by referencing the ID of the logo carousel you want to display.
[logocarousel id=1 /]
Advanced examples
Here, we’re using the shortcode to display a logo carousel by referencing the ID. If the carousel with the given ID is not found or it’s post status is either ‘trash’ or ‘draft’, it will not return anything. If the carousel is found, it will enqueue necessary styles and scripts, load dynamic styles, update options, and display the carousel.
[logocarousel id=2 /]
In this example, we’re using the shortcode to display a logo carousel by referencing the ID. If the carousel with the given ID is not found or it’s post status is either ‘trash’ or ‘draft’, it will not return anything. If the carousel is found, it will enqueue necessary styles and scripts, load dynamic styles, update options, and display the carousel. This example is similar to the previous one, but with a different ID.
[logocarousel id=3 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [logocarousel]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'logocarousel', array( $this, 'sp_logo_carousel_render' ) );
Shortcode PHP function:
function sp_logo_carousel_render( $attribute ) {
if ( empty( $attribute['id'] ) || 'sp_lc_shortcodes' !== get_post_type( $attribute['id'] ) || ( get_post_status( $attribute['id'] ) === 'trash' ) || ( get_post_status( $attribute['id'] ) === 'draft' ) ) {
return;
}
$post_id = esc_attr( intval( $attribute['id'] ) );
// All Options of Shortcode.
$logo_data = get_post_meta( $post_id, 'sp_lcp_shortcode_options', true );
ob_start();
// Stylesheet loading problem solving here. Shortcode id to push page id option for getting how many shortcode in the page.
// Get the existing shortcode ids from the current page.
$get_page_data = self::get_page_data();
$found_generator_id = $get_page_data['generator_id'];
if ( ! is_array( $found_generator_id ) || ! $found_generator_id || ! in_array( $post_id, $found_generator_id ) ) {
wp_enqueue_style( 'sp-lc-swiper' );
wp_enqueue_style( 'sp-lc-font-awesome' );
wp_enqueue_style( 'sp-lc-style' );
$dynamic_style = self::load_dynamic_style( $post_id, $logo_data );
// Load dynamic style.
echo '<style id="sp_lcp_dynamic_css' . esc_attr( $post_id ) . '">' . $dynamic_style['dynamic_css'] . '</style>';
}
// Update options if the existing shortcode id option not found.
self::lcp_db_options_update( $post_id, $get_page_data );
$main_section_title = get_the_title( $post_id );
self::splcp_html_show( $post_id, $logo_data, $main_section_title );
wp_enqueue_script( 'sp-lc-swiper-js' );
wp_enqueue_script( 'sp-lc-script' );
return ob_get_clean();
}
Code file location:
logo-carousel-free/logo-carousel-free/public/views/shortcoderender.php
Conclusion
Now that you’ve learned how to embed the Logo Carousel Plugin shortcode, 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.
Leave a Reply