Forums Forums Search & Filter Pro year dropdown

Viewing 10 posts - 11 through 20 (of 26 total)
  • Trevor
    #276135

    The Custom Layout plugin is not needed to add a year field. A year field can be made with code, but is is complex and the code would require annual maintenance. For now it would be best to hold off until V3 is released.

    Anonymous
    #276150

    Ok, thanks!
    Will v3 be launched this year?

    Trevor
    #276152

    I will be quite disappointed if it is not.

    Anonymous
    #276310

    Hi,

    Is this V3 add-on already released in the meantime?
    Or is there already another way to get this result:
    For ‘post date’ or ‘post_meta’ as date with a custom acf field (datepicker): Is it possible to make only a year dropdown (so no date picker)? A dropdown filter like: 2020, 2019, 2018, 2017 …

    L

    Trevor
    #276312

    It is not ready yet, I am sorry, and there is not another method to do as you want for now.

    Anonymous
    #276433

    Hello Just wondering. Are there any further updates on this?

    Trevor
    #276435

    Not at this time, I am sorry.

    Anonymous
    #276714

    Any update on this matter?
    I tried disabling the datePicker’s month and calendar with JS but wordpress seems to fail. Might be because of the posts query definition.

    Trevor
    #276716

    I am sorry, but not yet.

    Anonymous
    #276798

    I had this issue. I couldn’t find a solution here, so I created a very hacky javascript workaround that seems to work fine. Sharing it here in case anyone has a similar need to have a yearly dropdown and the developers don’t build it in.

    Here goes:

    1) Just after the filters in the theme template (index.php in my case) I have this:

    <li class=”moveme”>
    <select id=”years” class=”sf-input-select”>
    <option value=””>All Years</option>
    <?php wp_get_archives( array(
    ‘format’ => ‘option’,
    ‘type’ => ‘yearly’
    )); ?>
    </select>

    This creates a dropdown with all the years for which posts exist, with All Years added at the top.

    2) On the back end of the S&F plugin I added a Post Date field, set to date range, and a submit button.

    3) In my css stylesheet I hid the Post Date field and the submit button:

    .sf-field-submit,
    .sf-field-post_date,
    #primary > .moveme {
    display: none !important;
    }

    I’m also hiding the .moveme element when it first loads.

    4) Using jQuery/javascript I move the dropdown into the S&F form (where it becomes visible) on page load. When an option is selected, it populates the hidden Post Date fields with 1st Jan-31st Dec for the chosen year and clicks ‘submit’. The years dropdown gets reset when the form is reset.

    $(document).ready( function() {
    $(‘.moveme’).insertBefore(‘li.sf-field-post_date’).removeClass(‘moveme’);

    $(‘#years’).change(function() {
    var selectedValue = $(this).val();
    if (selectedValue == ” ) {
    $(‘.sf-datepicker’).val(”);
    } else {
    $(‘.sf-datepicker’).eq(0).val( ’01/01/’ + selectedValue.substr(selectedValue.length-5, 4 ));
    $(‘.sf-datepicker’).eq(1).val( ’31/12/’ + selectedValue.substr(selectedValue.length-5, 4 ));
    $(‘.searchandfilter .sf-field-submit input’).click();
    }
    });

    $(‘.search-filter-reset’).click(function() {
    $(‘#years’).val(”);
    });
    });

    NB. You’ll have to switch the order of 31/12 if you’re using American dates.

    Obviously this is sub-optimal, but hey, it works.

Viewing 10 posts - 11 through 20 (of 26 total)