• Resolved Anton42

    (@anton42)


    Hi,

    After updating to 1.14.0, displaying the shortcode from theme using <?php echo do_shortcode(‘[nivo …]’); ?> no longer works. It worked in previous versions.

    At the same time the shortcode works fine when inserted into regular posts.

    In the version release notes I wonder what the following statement means:

    Changed: Does not register the [nivo] shortcode until notified by ‘oik_add_shortcodes’

    For debugging I added output of global $shortcode_tags in the theme, and it looks like [nivo] shortcode somehow isn’t registered in this context.

    Trying to call bw_nivo_slider() directly with an array of parameters also doesn’t work, the function is not found.

    Please advise.

    https://www.ads-software.com/plugins/oik-nivo-slider/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Anton42

    (@anton42)

    OK, solved by replacing do_shortcode() with <?php echo apply_filters( ‘the_content’,'[nivo …]’); ?>

    I guess the registration process in Oik changed to use filters instead of proper shortcodes?

    Plugin Author bobbingwide

    (@bobbingwide)

    Hi Anton42, sorry about that. oik still uses proper shortcodes but it now doesn’t register them immediately.

    If you know you’ll be running a shortcode then another way would be to add
    do_action( “oik_add_shortcodes”);
    somewhere in your theme’s function.php, in response to “init”.
    or code it just before the do_shortcode().

    With apply_filters( ‘the_content’) there’s a risk that other filters will add things you didn’t really want.

    I have to do something like this in a theme where the 404 page doesn’t have any content but I have shortcodes in my footer which do need expanding.

    See:
    https://oik-plugins.com/oik_api/oik_do_shortcode/

    Do you think I should write a simpler routine that you can call in your theme to make this easier?
    Or have an option to register the shortcode(s) regardless of whether or not they’re found in the content.

    Thread Starter Anton42

    (@anton42)

    Hi Herb,

    Thank you, inserting do_action( “oik_add_shortcodes”); before my code solved the issue. And thanks for warning about hazards of using filters, I’ll keep that in mind.

    To be honest, I don’t think you need to make any changes, it would just be useful to mention the shortcodes caveat on Installation and/or FAQ pages of the plugin. Oik advertises their shortcodes all over, so it is jarring when they don’t work (though invoking from template PHP is not the most popular use-case, I understand that).

    Thank you again for your help, and for the great plugin too!

    Plugin Author bobbingwide

    (@bobbingwide)

    Hi, I’ve reverted the change in v1.14.1.

    The [nivo] shortcode will be registered in response to “oik_loaded”.

    It won’t do much harm to leave do_action( “oik_add_shortcodes” ) in your code,
    unless you don’t use any of the other shortcodes.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Theme's do_shortcode doesn't work for [nivo] from v1.14.0’ is closed to new replies.