Show ACF field in slider?

info's Avatar

info

05 Mar, 2021 05:40 PM

Hi there,

Could you help me with how to show a custom field - ie: date - shown in image attached.

Thank you,

Jim

  1. Support Staff 1 Posted by Dmitry Semenov on 07 Mar, 2021 01:08 PM

    Dmitry Semenov's Avatar

    Hello,

    You'll need to use slide markup editor for that, this may help http://help.dimsemenov.com/kb/wordpress-royalslider-advanced/wp-add...

  2. 2 Posted by info on 09 Mar, 2021 04:53 PM

    info's Avatar

    Hi there,

    Yes that does help -

    however how do i include 2 acf fields in the function?

    */* royalslider - Adding custom {{variables}} to Slide Markup Editor */*
    function newrs_add_acf_variable($m, $data, $options) {

        $m->addHelper('*date_start*', function() use ($data) {

               // $data is a WordPress post object (for posts-slider)

               // just return value
               return get_field( "*date_start*", $data->ID ) ;
        } );
    }

    add_filter('new_rs_slides_renderer_helper','newrs_add_acf_variable', 10, 4);

    // // //

    function newrs_add_acf_variable($m, $data, $options) {

        $m->addHelper('*date_end*', function() use ($data) {

               // $data is a WordPress post object (for posts-slider)

               // just return value
               return get_field( "*date_end*", $data->ID ) ;
        } );
    }

    add_filter('new_rs_slides_renderer_helper','newrs_add_acf_variable', 10, 4);

    =====

    *ACF use in slide markup - *

    <p class="date">{{date_start}} - {{date_end}}</p>

    _______________________________

    Jim Callender
    Director | Callender Creates Ltd.

    <https://www.callendercreates.com>

    E: [email blocked]
    M: 07888 701 588
    T: 01273 806 672
    <https://www.facebook.com/Callender-Creates-Digital-Design-Development-45151392331/>
       <https://twitter.com/jimcallender>
    <https://www.linkedin.com/in/callendercreates>

    This email and any files transmitted with it are confidential and intended
    solely for the use of the individual or organisation to whom they are
    addressed. If you have received this email in error please contact us.

  3. Support Staff 3 Posted by Dmitry Semenov on 09 Mar, 2021 05:01 PM

    Dmitry Semenov's Avatar

    Multiple can be added like this

    function newrs_add_acf_variables($m, $data, $options) {
    
      $m->addHelper('date_start', function() use ($data) {
        return get_field( "date_start", $data->ID ) ;
      } );
    
      $m->addHelper('date_end', function() use ($data) {
        return get_field( "date_end", $data->ID ) ;
      } );
    
    }
    
    add_filter('new_rs_slides_renderer_helper','newrs_add_acf_variables', 10, 4);
    

    not sure why you got * in your code, but keep them if it's the name of acf field.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Home_Page.png 39.5 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac