Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    The closest alternative would be to use Post Feed slides (Meta Slider Pro) where you can make use of the core WordPress features such as future publishing of posts. If you’re looking to set an expiry date you could use a plugin such as:
    https://wordpress.org/plugins/post-expirator/

    Using custom fields to set an expiry date of a slide in Meta Slider would require some significant code changes.

    Thanks,
    Dave

    This is itissue under a different username. I have found a simple solution for expiring slides.

    This little bit of code does the trick:

    $('.slides li').each(function(){
            if($(this).find('.expire').length) {
                var expireDate = new Date($(this).find('.expire').text()).getTime();
                var currentDate = new Date().getTime();
                if(expireDate < currentDate) {
                    $(this).remove();
                }
            }
        });

    And put this into the Meta Slider “General” field on a slide by slide basis:
    <span class="expire">2015/1/20</span>

    And for the CSS

    .expire {
        display: none;
    }

    The user will still have to delete the slide, but at least the slide disappears when expired.

    Sorry I gave the wrong information for the jQuery bit. Please use this instead:

    $('.slides li').each(function(){
            if($(this).find('.expire').length) {
                var expireDate = new Date($(this).find('.expire').text()).getTime();
                var currentDate = new Date().getTime();
                if(expireDate < currentDate) {
                    $(this).remove();
                }
            }
        });

    You’ll want to put it inside of the jQuery(document).ready(function($){}); So if you have other scripts in there, you can add it to there. In case people miss this, here’s a repeat of the other information:

    Put this into the Meta Slider “General” field on a slide by slide basis:
    <span class="expire">2015/1/20</span>

    And for the CSS

    .expire {
        display: none;
    }

    The user will still have to delete the slide, but at least the slide disappears when expired.

    Could you clarify as to where the jQuery should go?

    rattler98, you may add it in any javascript file that is after your jQuery library. You would also want it to be after the jQuery plugin for metaslider.

    For example, in this case, it’s in script.js in the theme directory. Generally you want this to be the last Javascript file loaded if you want to use it to control various plugins. Depending on how your site is set up, your scripts may be in the <head> rather than the bottom of the <body>. In this example, however, the scripts are at the bottom of the <body>.

    <!-- head stuff here -->
    <body>
    <!-- page content -->
    
    <script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.11.3'></script>
    <script type='text/javascript' src='/wp-content/plugins/ml-slider/assets/sliders/flexslider/jquery.flexslider-min.js?ver=3.3.5'></script>
    <-- other scripts -->
    <script type='text/javascript' src='/wp-content/themes/your-theme/js/script.js?ver=4.3.1'></script>
    </body>
    </html>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add custom field to Meta Slider’ is closed to new replies.