Date comparison in do_shortcode
-
Hi, this is more a suggestion than a question. Operators < > in things such as date comparison etc. echoed with do_shortcode function break rendering. For example such as this:
<?php echo do_shortcode('[ajax_load_more id="budouci_akce" preloaded="true" preloaded_amount="6" seo="true" theme_repeater="event.php" post_type="event" posts_per_page="6" meta_key="datum" meta_value="'.current_time('Y-m-d').'" meta_compare=">=" meta_type="DATE" order="ASC" orderby="meta_value" pause="true" scroll="false" button_label="'.__('Load more events','targito').'" button_loading_label="'.__('Loading events...','targito').'" button_done_label="'.__('All loaded','targito').'" no_results_text="'.__('There are no planned events right now.','targito').'"]'); ?>
There is an easy fix, however ALM is mentioning just “lessthan” string in their docs here https://connekthq.com/plugins/ajax-load-more/docs/code-samples/date-comparison/.
There are also other. I have been searching this for a while so please add it to the docs ALM team :).
Others are:
- $meta_compare = ‘lessthan‘ === $meta_compare ? ‘<‘ : $meta_compare;
- $meta_compare = ‘lessthanequalto‘ === $meta_compare ? ‘<=‘ : $meta_compare;
- $meta_compare = ‘greaterthan‘ === $meta_compare ? ‘>‘ : $meta_compare;
- $meta_compare = ‘greatthanequalto‘ === $meta_compare ? ‘>=‘ : $meta_compare;
- The topic ‘Date comparison in do_shortcode’ is closed to new replies.