Featured Image Caption Shortcode

Below, you’ll find a detailed guide on how to add the Featured Image Caption 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 Featured Image Caption Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Featured Image Caption Plugin and the shortcodes it provides:

Plugin Icon
Featured Image Caption

"Featured Image Caption is a WordPress plugin that allows you to effortlessly add, modify, or delete captions on your featured images, enhancing visual storytelling on your site."

★★★★✩ (27) Active Installs: 4000+ Tested with: 5.7.10 PHP Version: false
Included Shortcodes:
  • [ccfic]

Featured Image Caption [ccfic] Shortcode

The ‘ccfic’ shortcode is part of the featured-image-caption plugin. It’s used to display the caption of a featured image. The PHP code registers the ‘ccfic’ shortcode, linking it to a function that executes when the shortcode is used. A deprecated version, ‘cc-featured-image-caption’, is also included for backward compatibility.

Shortcode: [ccfic]

Examples and Usage

Basic example – Showcases the simple usage of the ‘ccfic’ shortcode without any additional parameters.

[ccfic /]

Advanced examples

1. Utilizing the shortcode to display a specific featured image caption by referencing the ID. In case the ID is not found, it will show a default caption.

[ccfic id="123" default="Default caption" /]

2. Incorporating the shortcode to display a specific featured image caption by referencing the title. If the title is not found, it will attempt to load by ID, and if both fail, it will show a default caption.

[ccfic title="Featured Image Title" id="123" default="Default caption" /]

Note: In the advanced examples, ‘id’ refers to the featured image ID, ‘title’ refers to the featured image title, and ‘default’ is the caption that will be displayed if the specified image is not found.

PHP Function Code

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

Shortcode line:

add_shortcode( 'ccfic', array( $shortcode, 'shortcode' ) );

Shortcode PHP function:

function shortcode() {
        $shortcode = new Shortcode();

        // Register the shortcode
        add_shortcode( 'ccfic', array( $shortcode, 'shortcode' ) );

        // DEPRECATED shortcode because hyphens are to be avoided.
        add_shortcode( 'cc-featured-image-caption', array( $shortcode, 'shortcode' ) );
    }

Code file location:

featured-image-caption/featured-image-caption/classes/Hooks.php

Conclusion

Now that you’ve learned how to embed the Featured Image Caption 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.

Comments

Leave a Reply

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